Reputation: 27
i have the problem that i want to add the class "not-editable-row" to a row based on a cell value in the same line, but it is not working. For testing i have tried "ui-state-error" and that is working. Does anyone know why the cells are still editable after i have added the class?
colNames:['city','country'],
colModel:[
{name:'city',index:'city', width:80,editable:true},
{name:'country',index:'country', width:80,editable:true},
],
......
loadComplete: function () {
var ids = grid.jqGrid('getDataIDs');
for (var i=0;i<ids.length;i++) {
var id=ids[i];
if (grid.jqGrid('getCell',id,'city') !== 'Berlin') {
$('#' + $.jgrid.jqID(id)).addClass('not-editable-row');
$('#' + $.jgrid.jqID(id)).addClass('ui-state-error');
}
}
},
Thanks for your help, Felix
Upvotes: 1
Views: 2213
Reputation: 221997
I suppose that you try using cell editing or form editing instead of inline editing. The class "not-editable-row"
added to the row (to <tr>
elements) will be used only by inline editing (see the documentation). Other editing modes just ignore the class.
By the way if you need set some classes to some rows of the grid you should better use rowattr
. See the answer for more details.
Upvotes: 2
Reputation: 16719
As stated in the jqGrid documentation, the loadComplete
"event is executed immediately after every server request." Hence, your data may not be completely loaded into the grid yet. Try using gridComplete
instead, which "fires after all the data is loaded into the grid and all other processes are complete. Also the event fires independent from the datatype parameter and after sorting paging and etc."
Upvotes: 0