PDA

View Full Version : Setting editorGrid column to read only



darkling235
11 Jan 2010, 8:30 AM
I'm using an editorGrid to show data but some columns are supposed to be read only for certain users. Is there anyway to do this other than waiting until they try to save and stopping them from committing the change to a cell?
Thanks

micgala
12 Jan 2010, 2:34 AM
Yes, there is a way:

Add a BeforeEdit to your grid, and set the grid setCancelled to true when you want to deny the edition, like this:



addListener(Events.BeforeEdit, new Listener<GridEvent<?>>() {
public void handleEvent(GridEvent<?> gridEvent) {
gridEvent.setCancelled(true);
}
});

darkling235
12 Jan 2010, 4:11 AM
Thank you.

darkling235
12 Jan 2010, 8:09 AM
Thank you