tags:

views:

85

answers:

2

Hi,

how to set the fourth parameter of the setCell method : the class parameter

$("#myGrid").jqGrid('setCell',rowid,'label', **class** ,{color:'black', weightfont:'bold'});

Thank you !

+1  A: 

You can just define in your CSS file a new class like

.MyCell {
  color:'black';
  weightfont:'bold'
}

and then use

$("#myGrid").jqGrid('setCell',rowid,'label', '', 'MyCell');

It seems to me that following will also work

$("#myGrid").jqGrid('setCell',rowid,'label', '', {color:'black', weightfont:'bold'});

Oleg
Thank you for your quick response!yes this capability works: $("#myGrid").jqGrid('setCell',rowid,'label', '', {color:'black', weightfont:'bold'});but in addition, I would like to apply a jquery UI class to my cell, for example the .ui-state-default classYou can find the definition of setCell method at http://www.secondpersonplural.ca/jqgriddocs/_2eb0fi5wo.htm# But what's that mean about class parameter ?
Qualliarys
you can call `$("#myGrid").jqGrid('setCell',rowid,'label', '', 'ui-state-default');` in the next line for example after ` $("#myGrid").jqGrid('setCell',rowid,'label', '', {color:'black', weightfont:'bold'});`. jqGrid just call `jQuery.addClass` for the corresponding `<td>` element of grid and with the corresponding parameters. So you can have multiple "add" operations. Don't forget to do this inside of `loadComplete` or other event handler like `onSelectRow`. Then you can be sure, that the grid is completely filled to the moment.
Oleg
+1  A: 

Thanks a lot, it works now !

I simply wrote :

afterInsertRow: function(rowid){    
  $("#myGrid").jqGrid('setCell',rowid,'label','',{color:'gray', weightfont:'bold'});
  $("#myGrid").jqGrid('setCell',rowid,'label', '', 'ui-state-default');
},
Qualliarys
I recommend you use `gridview: true` always, especially if you allow user to display large number of rows at the same time. Then all rows (`<tr>` with the full contain) will be first collected in one Array of strings and then all added with respect of one `Array.join` operation. If you use `afterInsertRow` you break usage of `Array.join` inside of `addXmlData` or `addJSONData` implementation. So I find better to call `jqGrid('setCell',...);` one time inside of `loadComplete` event handler. Then you will have the same results, but everything will work more quickly.
Oleg
Oleg
Oleg, Thanks a lot for these useful information.
Qualliarys