json - JQgrid not showing data while rows are generating -


jqgrid not showing json data, rows generating

server side code:

public jsonresult denominations() { . . int counter = 0; var jsondata = new { total = result.userobject.count, page = 1, rows = (       p in result.userobject       select new       {             id = ++counter,             cell = new string [] {                     p.currencyid.tostring(),                     p.denominationid.tostring(),                     p.denominationname.tostring(),                     p.denominatorcount.tostring(),                     p.multiplier.tostring(),                     p.tenderid.tostring()                      }                  }).toarray()              };             return json(jsondata, jsonrequestbehavior.allowget); } 

data server side this: {"total":1,"page":1,"rows":[{"id":1,"cell":["1","1","penny","0","0.0100","1"]}]}

javascript code:

$("#denominators").jqgrid({         url: '/denominations?tenderid=1&currencyid=1',         contenttype: "application/json",         datatype: "json",         jsonreader: {             root: 'rows',             page: 'page',             total: 'total',             repeatitems: false,             cell: 'cell',             id: 'id',             userdata:'userdata'         },         mtype: "get",         colnames: ["currencyid", "denominationid", "tenderid", "multiplier", "denominationname", "denominatorcount"],         colmodel: [             { name: "currencyid", width: 80, align: "center" },             { name: "denominationid", width: 90, align: "center" },             { name: "tenderid", width: 250 },             { name: "multiplier", width: 250 },             { name: "denominationname", width: 95 },             { name: "denominatorcount", width: 95 },         ],         height: 'auto',         loadonce: true,         sortname: "denominationid",         sortorder: "desc",         viewrecords: true,         gridview: true,         autoencode: true     }); 

view:

<table id="denominators" ></table> 

view creates grid column header rows generated rows did not data int.

you use wrong jsonreader. property repeatitems: false false. means format of every item in rows array is

{     "currencyid": "1",     "denominationid": "1",     "tenderid": 1,     "denominationname": "penny",     "denominatorcount": "0",     "multiplier": "0.0100" } 

you use

{     "id": 1,     "cell": [         "1",         "1",         "penny",         "0",         "0.0100",         "1"     ] } 

instead. should remove jsonreader because format of input data corresponds default jsonreader, need still reorder columns of grid or change order of items place in cell array corresponds order of columns in colmodel.

additional remarks: use wrong value total. should number of pages. way use loadonce: true. in case can remove "total":1,"page":1 part response , return array of named items. should choose names of columns same names of properties if items.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -