kendo Grid加载远程数据方式

阅读更多
kendo Grid官网提供的远程加载数据的方式在实际中其实不可行的。下面是它在官网中加载数据的例子:

           

           
       

在demo里面远程的数据返回的是一个类似于数据列表,但是在实际项目中,我们ajax返回的是一个对象集合,这个对象里面存放了一个数组,安装它上面的方式是不能直接加载出数据的。
$("#example").kendoGrid({
             dataSource: {
                 transport: {
                     read: url,
                     dataType:"json"
                 },
                 schema: {
                     data:"data",//ajax返回的对象
                     model: {
                     //数据字段的映射
                         fields: {
                             id: { type: "string" },
                             status: { type: "string" },
                             queue: { type: "string" },
                             submitTime: { type: "String" },
                             executionHost: { type: "string" },
                             name:{type:"string"}
                         }
                     }
                
                 },
                 //分页信息
                 pageSize: 11,
                 serverPaging: false,
                 serverFiltering: false,
                 serverSorting: false
             },
             selectable: "multiple",
             navigatable: true,
             height: 473,
             filterable: true,
             sortable: true,
             pageable: true,
             //列的映射
             columns: [{
                     field:"id",
                     title:$.i18n.prop("appform.job.inf.id")
                 }, {
                     field:"status",
                     title: $.i18n.prop("appform.job.inf.stat")
                 }, {
                     field:"queue" ,
                     title: $.i18n.prop("appform.job.inf.queue")
                 }, {
                     field:"submitTime" ,
                     title: $.i18n.prop("appform.job.inf.submitTime"),
                     format: "{0:MM/dd/yyyy}"
                 },{
                     field:"executionHost" ,
                     title: $.i18n.prop("appform.job.inf.executeNode")
                 }, {
                     field:"name" ,
                     title: $.i18n.prop("appform.job.inf.name")
                 }
             ]
         });
文章转自:IT家园 http://wgyblog.com/html/artwebfront/131.html

你可能感兴趣的:(json)