PDA

View Full Version : Disabling Cells in an editor grid



darkling235
9 Mar 2011, 4:28 AM
I have an editor grid that has 4 columns. The second column is a combobox and if a certain value is selected in that combobox, users should not be permitted to enter values into columns 3 and 4. I've seen a few ideas on the forum but I'm not sure what the best practices are for disabling specific cells based on a prior value in that same row. Can anyone give me some suggestions?
Thanks

blay
9 Mar 2011, 6:49 AM
Just add a listener to the BeforeEdit event, and then check if conditions let user edit or not. In case they donĀ“t, cancel the event.




grid.addListener(Events.BeforeEdit, new Listener<GridEvent<ModelData>>(){

public void handleEvent(GridEvent<ModelData> be){
Record record = be.getRecord();
YourComboType value = (YourComboType) record.get("property2ndcolumn");
if (value.equals(whatever) && (be.getProperty().equals("thirdcolumn") || be.getProperty().equals("fourthcolumn"))
be.setCancelled(true);
}


});