PDA

View Full Version : how to make a Ext.grid.EditorGridPanel readonly



shahab_et
18 Jan 2011, 1:02 AM
Hi,
I have a form that is used for data Entry ,viewing and modify the saved records.
but when viewing data I need the editorGridPanel to be read only so that user can not make any changes.

how do I make the grid read only ,when I need it ?

Note : the grid shouldn't be disabled because there is a vertical scroll bar ,and user should be able to scroll through all the columns and rows (just to view )

Thank you,

Condor
18 Jan 2011, 1:16 AM
There are several solutions, but the simplest is probably to return 'false' from the beforeedit grid event.

vishalnnsingh
18 Jan 2011, 1:18 AM
Use this:
for(i=1;i<=grid.getColumnModel().getColumnCount(true);i++)
grid.getColumnModel().setEditable( i, false );

vishalnnsingh
18 Jan 2011, 1:19 AM
@condor Am i doing a lot of work for a simple thing...

Condor
18 Jan 2011, 1:21 AM
As I said, there are several ways to do this. My solution isn't any better than yours, it just takes less code.

vishalnnsingh
18 Jan 2011, 1:24 AM
listeners:{
beforedit:function(){
return false;
}
},

This isn't working

shahab_et
18 Jan 2011, 1:26 AM
Thank you both,

since I have some "actioncolumn" columns in the grid there might still be some problems
eg: user might click on a cell (which is not editable but still clickable and changing data is still possible)

Condor
18 Jan 2011, 2:38 AM
@vishalnnsingh: It's beforeedit.

@shahab_et: Yes, an ActionColumn doesn't actually edit the grid, so it is still allowed when the grid is read-only. You'll have to add a check to your action handlers to see if clicking them is allowed.

vishalnnsingh
18 Jan 2011, 3:04 AM
M sorry, thanks