json - How to Bind jqGrid with asmx webservice C# -


please need in how bind jqgrid asmx webservice c# , found topics in how convert asmx webservice json it's not clear me

regards

first of should define webmethod provide data jqgrid. if plan implement server side sorting , paging webmethod should have @ least following parameters

public jqgriddata testmethod (int page, int rows, string sidx, string sord) 

where jqgriddata class defined example like

public class tablerow {     public int id { get; set; }     public list<string> cell { get; set; } } public class jqgriddata {     public int total { get; set; }     public int page { get; set; }     public int records { get; set; }     public list<tablerow> rows { get; set; } } 

there other different options how 1 can fill grid, it's first important understand @ least 1 way.

it's important, return json data web method you don't need convert returned data manually json. need return object data , asmx web service serialize object xml or json based on headers of http request.

it request server have application/json; charset=utf-8 or application/json in content-type part of http header, returned data json ,

{     "d": {         "page": 1,         "total": 4,         "records": 4,         "rows": [             ...         ]     } } 

on client side should use

$("#list").jqgrid({     url: 'mytestws.asmx/testmethod',     datatype: 'json',     mtype: 'post',     ajaxgridoptions: { contenttype: 'application/json; charset=utf-8' },     serializegriddata: function (postdata) {         return json.stringify(postdata);     },     jsonreader: {         root: "d.rows",         page: "d.page",         total: "d.total",         records: "d.records"     }     gridview: true,     ... } 

see here code example.

updated: here , here can download visual studio demo projects. see the answer more links other demo projects.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -