jquery - jqGrid v4 - dynamic column not working -


controller code:

 public jsonresult getgridcolumn()  {     var jsondata = new     {        colnames = "['actname']",        colmodel = "[{ name: 'actiontaken'}]",       };       return json(jsondata, jsonrequestbehavior.allowget);     }   } 

view code :

$(document).ready(function () {     $.ajax({         type: "post",         url: "/getform/getgridcolumn",         data: "",         datatype: "json",         success: function (data) {             coln = data.colnames;             colm = data.colmodel;             $("#taskgrid").jqgrid({                 url: "someurl",                 datatype: 'jsonstring',                 mtype: 'post',                 colnames: coln,                 colmodel: colm,                 pager: jquery('#pager'),                 rownum: 10,                 rowlist: [10, 20, 30, 40],                 height: '100%',                 viewrecords: true,                 width: 1250,                 jsonreader: {                     cell: "",                     id: "0"                 }             })         }     }); }); 

i coln ['actname'] , colm [{ name: 'actiontaken'}]. when run above script error length of colnames<> colmodel!

try like

var jsondata = new {         colnames = new [] {"actname"},         colmodel = new [] { new { name = "actiontaken" } }     }; 

in way jsondata.colnames , jsondata.colmodel should arrays , not strings. jqgrid verify both arrays has same number of elements, use colnames , colmodel strings , test if (p.colnames.length !== p.colmodel.length) { compares length of strings in case. it's reason of misunderstandable error message.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -