View Full Version : Disable Cell Editing in GXT 2.1 Grid

10 May 2010, 10:46 PM
How to conditionally disable editing for any cell in the gxt 2.1 grid?
The column is enabled initially for all rows but on certain conditions one of its cell needs to be disabled.

10 May 2010, 11:57 PM
Well, this is one possible way of doing it:

editorGrid.addListener(Events.BeforeEdit, new Listener<GridEvent<YourModel>>() {
public void handleEvent(GridEvent<YourModel> be) {
if (certain condition) {
be.setCancelled(true); //Disable edition


12 May 2010, 9:05 PM
I tried...it works..
Thanks a lot.

16 Apr 2014, 12:54 AM
I am facing the similar issue.I need to disable and enable the cell based on the value in the another cell.I am using Editor Grid of GXT 2.2.3.I tried the below code.But it's disabling fine but once it's disabled and if I select someother value it's not able to re-enable it.Please suggest how to resolve this.Please find the code below:

Listener<GridEvent<AttendanceCaseCreationModel>> gridAfterEditListener = new Listener<GridEvent<AttendanceCaseCreationModel>>() { @Override public void handleEvent(GridEvent<AttendanceCaseCreationModel> be) { AttendanceCaseCreationModel data = be.getModel(); String val = data.get("event"); if(val.equalsIgnoreCase("Remove Attendance")){ data.set("checkinDate",""); grid.getColumnModel().getColumnById("checkinDate").getEditor().disable(); grid.getStore().update(data); grid.getView().refresh(true); } else { data.set("checkinDate",""); grid.getColumnModel().getColumnById("checkinDate").getEditor().enable(); grid.getStore().update(data); grid.getView().refresh(true); } } }; grid.addListener(Events.AfterEdit, gridAfterEditListener);

Please help me.