0

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 !

Qualliarys
  • 143
  • 2
  • 4
  • 14

3 Answers3

3

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
  • 220,925
  • 34
  • 403
  • 798
  • 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 class You can find the definition of setCell method at http://www.secondpersonplural.ca/jqgriddocs/_2eb0fi5wo.htm# But what's that mean about class parameter ? – Qualliarys May 20 '10 at 15:51
  • 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 `` 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 May 20 '10 at 16:09
3

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');
},
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
Qualliarys
  • 143
  • 2
  • 4
  • 14
  • 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 (`` 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 May 20 '10 at 16:44
  • If you want redefine class of all rows you can redefine `.ui-jqgrid tr.jqgrow td` in your css. If you change padding values, then it can be needed to redefine `cellLayout` option of jqGrid (see http://www.trirand.com/blog/?page_id=393/feature-request/celllayout/&value=cellLayout&type=1&include=1&search=1&ret=all) – Oleg May 20 '10 at 16:48
1

I have used below code

$('#'+gridTable).jqGrid('setLabel', "abc", "new Label");

runs perfectly

But if i tried to change it again like

$('#'+gridTable).jqGrid('setLabel', "new Label", "new Label123");

Above code not gives an error but value of label is not changing..

Manish
  • 25
  • 1
  • 6