JQGrid: Dynamically set a cell to uneditable based on content
Posted
by
Shawn
on Stack Overflow
See other posts from Stack Overflow
or by Shawn
Published on 2011-01-17T22:51:03Z
Indexed on
2011/01/17
22:53 UTC
Read the original article
Hit count: 206
I'm having some issues getting some cells (with cellEdit: true) to be non-editable even though the column is set to editable.
I've tried many ways, like beforeEditCell, formatters, etc. None seem to work.
The closest I've got is by setting a formatter to the column that I'd like to be editable and then using setCell to set the 'not-editable-cell' class (snippet below). The first time you click the cell, it unfortunately goes into edit mode, but if you click elsewhere and try to re-edit the cell, it's successfully uneditable.
I've also tried using the same snipped but inside of beforeEditCell, it successfully stops the cell from being edited but in turn 'freezes' the grid. You can no longer select any other cell.
function noEditFormatter(cellValue, options, rowObject) {
if (cellValue == 'test')
jQuery("#grid").jqGrid('setCell', options.rowId, 'ColName', '', 'not-editable-cell');
return cellValue;
}
Any help would be much appreciated.
© Stack Overflow or respective owner