, , (. ). , jqGrid
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" };
rows, page, total records , , jsonReader
jsonReader: {
root: function (obj) { return obj.d; },
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.d.length; }
}
( ). , , , loadonce:true.
, . , JavaScriptSerializer.Serialize -. dataType: "json", JSON $.ajax. . - msg success d. msg.d - , JSON, eval(msg.d). , JSON .
, - GetUsersJSON :
[WebMethod]
[ScriptMethod (ResponseFormat = ResponseFormat.Json)]
public static List<User> GetUsersJSON()
{
using(UserAdministrationSandboxDataContext uasd =
new UserAdministrationSandboxDataContext())
{
return uasd.GetUserList();
}
}
data: eval(msg.d) data: msg.d.
- [ScriptMethod (ResponseFormat = ResponseFormat.Json)] [ScriptMethod (UseHttpGet = true, ResponseFormat = ResponseFormat.Json)], (, ) .
ajaxGridOptions, serializeGridData jsonReader jqGrid , JSON, JSON, .
. , repeatitems:false jsonReader, . , jsonReader, .
, , JSON jqGrid. . ,
1) ,
{"Username":"TestUser","Email":"TestUser@test.com","Comment":"..","IsApproved":true}
2) ,
["TestUser","TestUser@test.com","true"]
["TestUser","TestUser@test.com","1"]
jqGrid "true" "1" "true" edittype:'checkbox'. , -, "1" / "0" .
repeatitems:false , jqGrid JSON () . repeatitems:true ( ).
, (repeatitems:false), cell jsonReader , cell:'', .
id jsonReader , . id:'0' , " " . Firebug IE Chrome, , <tr> id="TestUser" ( ). HTML , , . jqGrid id , "1" , "2",... , , , id jsonReader.
: (repeatitems:false) (repeatitems:true)
(repeatitems:true) .
- . , , "" , jqGrid.
- , ( ) .
, , , (repeatitems:true) . , cell:'' jsonReader .
jqGrid jsonReader, xmlReader localReader.