c# - Jqgrid not binding data -



c# - Jqgrid not binding data -

i getting json response webservice below

json returns info perfectly. info looks

{"d":"[{\"id\":2,\"code\":\"mycode\",\"name\":\"myname\",\"password\":\"a\",\"clientlevel\":0,\"deptno\":\"\",\"deptname\":\"\"},{\"id\":3,\"code\":\"mycode\",\"name\":\"ly1\",\"password\":\"mypassword\", ....... not binding jqgrid.

and have next jqgrid code

jquery("#list2").jqgrid({ mtype: 'post', url: "myservice.asmx/getqueryinfo", serializegriddata: function (postdata) { homecoming json.stringify({ tablenames: tablename, columnlist: columnnames }); }, ajaxgridoptions: { contenttype: "application/json; charset=utf-8" }, jsonreader: { repeatitems: false, root: 'd', page: function (obj) { homecoming 1; }, total: function (obj) { homecoming 1; }, records: function (obj) { homecoming obj.tostring().length; } }, datatype: 'json', colnames: ['id', 'code', 'name', 'password', 'clientlevel', 'deptno', 'deptname'], colmodel: [ { name: "id", width: 55 }, { name: "code", width: 90 }, { name: "name", width: 100 }, { name: "password", width: 80 }, { name: "clientlevel", width: 80 }, { name: "deptno", width: 80 }, { name: "deptname", width: 150 } ], autoencode: true, gridview: true, rownum: 10, loadonce: true, rowlist: [10, 20, 30], pager: '#pager2', sortname: 'id', viewrecords: true, sortorder: "id", caption: "json example", loaderror: function (jqxhr, textstatus, errorthrown) { alert('http status code: ' + jqxhr.status + '\n' + 'textstatus: ' + textstatus + '\n' + 'errorthrown: ' + errorthrown); alert('http message body (jqxhr.responsetext): ' + '\n' + jqxhr.responsetext); } }); jquery("#list2").jqgrid('navgrid', '#pager2', { edit: false, add: false, del: false });

i still think utilize old code on server side (webmethod returns string instead of object) because value of d property string. can utilize root in jsonreader function defined in the answer. in case works in case too. can use

jsonreader: { repeatitems: false, root: function (obj) { homecoming typeof obj.d === "string" ? $.parsejson(obj.d) : obj.d; } }

c# asp.net json web-services jqgrid

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -