jquery - Kendo Grid is not displaying json data webforms -


i'm new comer kendo grid, i'm using webmethod trigger it. of lots of forums, i'm able trigger request webmethod. problem method returning number of records in json format. simplicity, consider 1 hardcoded json record here response:

{"d":"{\"pk_picture\":22,\"p_displayorder\":1,\"altattribute\":\"smith\",\"titleattribute\":\"smith\"}"}  <script>                 $(document).ready(function () {                      $("#productpictures-grid").kendogrid({                         height: 200,                         columns: [                             { field: "pk_picture", title: "picture",  width: "150px" },                             { field: "p_displayorder", width: "150px" },                             { field: "altattribute", width: "100px" },                             { field: "titleattribute", width: "100px" },                             { command: "destroy", title: "delete", width: "110px" }                         ],                         pageable: {                             info: true                         }, // enable paging                         //filterable: true, // enable filtering                         //sortable: true, // enable sorting                         editable: true, // enable editing                         //toolbar: ["create", "save", "cancel"], // specify toolbar commands                         datasource: {                             serverpaging: true,                             serversorting: true,                             serverfiltering: true,                             pagesize: 10,                             schema: {                                 data: "d.results", // web methods return json in following format { "d": <result> }. specify how result.                                 total: "d.total",                                 model: { // define model of data source. required validation , property types.                                     fields: {                                         pk_picture: { editable: false, type: "string" },                                         p_displayorder: { editable: true, type: "string" },                                         altattribute: { editable: true, type: "string" },                                         titleattribute: { editable: true, type: "string" }                                     }                                 }                             },                            // batch: true, // enable batch editing - changes saved when user clicks "save changes" button                             transport: {                                 create: {                                     url: "testpage.aspx/create", //specify url should create new records. create method of products.asmx service.                                     contenttype: "application/json; charset=utf-8", // tells web method serialize json                                     type: "post" //use http post request default not allowed web methods                                 },                                 read: {                                     url: "update.aspx/fillproductdatabyid", //specify url data should return records. read method of products.asmx service.                                     contenttype: "application/json; charset=utf-8", // tells web method serialize json                                     type: "post" //use http post request default not allowed web methods                                 },                                 update: {                                     url: "testpage.aspx/update", //specify url should update records. update method of products.asmx service.                                     contenttype: "application/json; charset=utf-8", // tells web method serialize json                                     type: "post" //use http post request default not allowed web methods                                 },                                 destroy: {                                     url: "testpage.aspx/destroy", //specify url should destroy records. destroy method of products.asmx service.                                     contenttype: "application/json; charset=utf-8", // tells web method serialize json                                     type: "post" //use http post request default not allowed web methods                                 },                                 parametermap: function (data, operation) {                                     if (data.models) {                                         return json.stringify(data);                                         return json.stringify({ products: data.models });                                     } else if (operation == "read") {                                         //page methods need values parameters                                         data = $.extend({  productids: $('#id').val() }, data);                                         return json.stringify(data);                                     }                                 }                             }                         }                     });                 });             </script> 

here server method

    [webmethod] public static string fillproductdatabyid(string productids) {     blproduct objproduct = new blproduct();     string json = jsonconvert.serializeobject(new { pk_picture = 22, p_displayorder = 1, altattribute = "smith", titleattribute = "smith" });     return json;     //datatable dt = new datatable();     //dt = objproduct.getproductbyproductid(productids);     //return jsonconvert.serializeobject(dt); } 

please help

it seems json return server not array. json data server kendo shoud array.

for example:

[{"pk_picture":22,"p_displayorder":1,"altattribute":"smith","titleattribute":"smith"}, {{"pk_picture":33,"p_displayorder":2,"altattribute":"hamed","titleattribute":"hamed"}] 

so this:

[webmethod] public static string fillproductdatabyid(string productids) {     blproduct objproduct = new blproduct();     datatable dt = new datatable();     dt = objproduct.getproductbyproductid(productids);     var dataarray = dt.asenumerable().toarray();     return jsonconvert.serializeobject(dataarray); } 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -