jquery - How to add a style class in jqGrid Td using asp.net c# -


i want conditionaly change style of td in jqgrid, tried lots of example not worked, think doing wrong, please view code , me find out correct code.

my code is

$(function () {      $("#datagrid").jqgrid({         url: 'client.aspx/load_conversation',         datatype: 'json',         mtype: 'post',          serializegriddata: function (postdata) {             return json.stringify(postdata);         },          ajaxgridoptions: { contenttype: "application/json" },         loadonce: false,         reloadgridoptions: { fromserver: true },         colnames: ['conversation', 'adminstatus'],         colmodel: [{ name: 'conversation', index: 'message', width: 245 }, { name: 'adminstatus', index: 'isadmin' }, ],         gridcomplete: function () {             var ids = jquery("#datagrid").jqgrid('getdataids');             (var = 0; < ids.length; i++) {                 var status = jquery("#datagrid").jqgrid("getcell", ids[i], 'adminstatus');                  if (status == "false") {                     $j('#' + ids[i]).removeclass("ui-widget-content");                     $j('#' + ids[i]).addclass("changestyle");                 }             }         },         viewrecords: true,         gridview: true,         jsonreader: {             records: function (obj) { return obj.d.length },             root: function (obj) { return obj.d },             repeatitems: false,             caption: 'live chat us'         }     });     $("#datagrid").hidecol("adminstatus");     $("#datagrid").jqgrid('setgridheight', 240); }); 

my code behind is

   public static list<dictionary<string, object>> load_conversation()     {         webservice wb= new webservice();         datatable dt = wb.get();         system.web.script.serialization.javascriptserializer serializer = new system.web.script.serialization.javascriptserializer();         list<dictionary<string, object>> rows = new list<dictionary<string, object>>();         dictionary<string, object> row;         foreach (datarow dr in dt.rows)         {             row = new dictionary<string, object>();              row.add("conversation", dr["messgae"]);             row.add("adminstatus", dr["isadmin"]);             rows.add(row);         }         return rows;     } 

if correcly understand format of data returned server should remove gridcomplete, remove index properties colmodel , use cellattr in adminstatus if need change style of <td> elements in adminstatus:

colmodel: [     { name: 'conversation', width: 245 },     { name: 'adminstatus', cellattr: function (rowid, val) {          if (val === "false") {              return " class='changestyle'";          }      }} ] 

you can see example of close usage of cellattr in the answer.

it important how defines css rule on changestyle class. if don't see expected results have include definition of css rule of changestyle class , version of jqgrid use.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -