jquery - JqGrid Load Json data from controller -


i using jqgrid , want display grid jquery call controller return me json data grid did not show data code here

public jsonresult getplainobjectasjson()         {             var rows = (getdatalist()                 .select(c => new                 {                     id = c.catid,                     cell = new []                                         {                                             c.catid.tostring(),                                             c.catname,                                             c.desc,                                             c.desc1,                                             c.desc10,                                             c.desc11,                                             c.desc12,                                             c.desc13,                                             c.desc14,                                             c.desc15,                                             c.desc16,                                             c.desc17,                                             c.desc18,                                             c.desc19,                                             c.desc2,                                             c.desc20,                                             c.desc21,                                             c.desc22,                                             c.desc23,                                             c.desc24,                                             c.desc25,                                             c.desc3,                                             c.desc4,                                             c.desc5,                                             c.desc6,                                             c.desc7,                                             c.desc8,                                             c.desc9,                                             c.proid.tostring(),                                             c.proname                                         }                 })).toarray();             return new jsonresult             {                 data = new                 {                     page = 1,                     records = rows.length,                     rows,                     total = 1                 }             };          } 

this function generate json data , function

return json result

  public jsonresult getplainobject()         {              var res = getplainobjectasjson();              return json(res, jsonrequestbehavior.allowget);         } 

and here index page

<script type="text/javascript">         $(document).ready(function () {         debugger;         $("#treegrid").jqgrid({             url: '@url.content("~/treegrid/getplainobject")',             datatype: "json",             mtype: "get",             colnames: ["catid", "catname", "desc", "desc1", "desc10", "desc11", "desc12", "desc13", "desc14", "desc15", "desc16", "desc17", "desc18",                 "desc19", "desc2", "desc20", "desc21", "desc22", "desc23", "desc24", "desc25", "desc3", "desc4", "desc5", "desc6",                 "desc7", "desc8", "desc9", "proid", "proname"],             colmodel: [             { name: "catid", index: "catid", width: 150, key: true },             { name: "catname", index: "catname", width: 200 },             { name: "desc", index: "desc", width: 200 },             { name: "desc1", index: "desc1", width: 300 },             { name: "desc10", index: "desc10", width: 300 },             { name: "desc11", index: "desc11", width: 150 },             { name: "desc12", index: "desc12", width: 200 },             { name: "desc13", index: "desc13", width: 300 },             { name: "desc14", index: "desc14", width: 150 },             { name: "desc15", index: "desc15", width: 200 },             { name: "desc16", index: "desc16", width: 300 },             { name: "desc17", index: "desc17", width: 150 },             { name: "desc18", index: "desc18", width: 200 },             { name: "desc19", index: "desc19", width: 300 },             { name: "desc2", index: "desc2", width: 150 },             { name: "desc20", index: "desc20", width: 150 },             { name: "desc21", index: "desc21", width: 200 },             { name: "desc22", index: "desc22", width: 300 },             { name: "desc23", index: "desc23", width: 150 },             { name: "desc24", index: "desc24", width: 200 },             { name: "desc25", index: "desc25", width: 300 },             { name: "desc3", index: "desc3", width: 200 },             { name: "desc4", index: "desc4", width: 300 },             { name: "desc5", index: "desc5", width: 150 },             { name: "desc6", index: "desc6", width: 200 },             { name: "desc7", index: "desc7", width: 300 },             { name: "desc8", index: "desc8", width: 150 },             { name: "desc9", index: "desc9", width: 200 },             { name: "proid", index: "proid", width: 300 },             { name: "proname", index: "proname", width: 150 }              ],               height: "auto",             rownum: 10,             rowlist: [10, 20, 30],             pager:"#pager",             gridview: true,             viewrecords: true,             caption: "tree grid example",             jsonreader : {             root: "data",             page: "page",             total: "total",             records: "records"              }          });        });  </script> 

help me m wrong ....

i think should remove unneeded getplainobjectasjson method return jsonresult. should not use jsonresult parameter of json. instead of can include code main code of getplainobjectasjson inside of getplainobject , place

return json(new {                 page = 1,                 records = rows.length,                 rows,                 total = 1             }, jsonrequestbehavior.allowget); 

additionally should remove jsonreader client code , include loadonce: true instead. allow use local sorting, paging , sorting/filtering of data in jqgrid. can remove colmodel index properties because there has same values name property.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -