0

我有一个网格,它绑定来自 DataSource 的数据,但它不显示数据,我可以看到来自服务器的数据,但网格保持为空,这是我的代码:

var dts = new kendo.data.DataSource({
  type: "json",
  serverPaging: true,
  pageSize: 20,
  group: { field: 'ProductType' },
  transport: {
    read: {
      url: "http://someurl.com", // the remove service url
      dataType: "json" ,// JSONP (JSON with padding) is required for cross-domain AJAX
      type: "GET", 
    },
  parameterMap: function(options) {
    return {
      //Some parameters
      };
    }
  }    
});

var grid = $("#grid").kendoGrid({
  dataSource: dts,
  navigatable: true,
  sortable: true,
  audoBind: false,
  height: 240,
  pageable: false,
  scrollable: false,
  columns: [
    {
      field: "SKU",
      width: 100,
      title: "SKU"
    }, {
      field: "ItemDescription",
      width: 150,
      title: "DescriptionDescription"
    }, {
      field: "Quantity",
      width: 80,
      title: "QTY"
    }, {
      field: "UOM",
      width: 80,
      title: "UOM"
    }, {
      field: "UnitPrice",
      width: 130,
      title: "UnitPrice",
      format: "{0:c}"
    }, {
      field: "Tax",
      width: 80,
      title: "Tax",
      format: "{0:c}"
    }, {
      field: "Total",
      width: 80,
      title: "Total",
      format: "{0:c}"
    }
  ]
}).data("kendoGrid");

dts.read();

这是我的代码,首先创建数据源“dts”,然后创建网格“grid”,最后调用读取函数“dts.read()”。DataSource 从服务器读取数据,但它没有显示在 Grid 上。

任何帮助将不胜感激!

4

1 回答 1

1

您的数据源可能存在一些问题,因为我无法使用 kendo UI 的服务重现此问题。

<script>

var dts = new kendo.data.DataSource({
    type: "odata",
    transport: {
        read: "http://demos.kendoui.com/service/Northwind.svc/Orders",
        dataType: "jsonp" ,
    },
    schema: {
        model: {
            fields: {
                OrderID: { type: "number" },
                Freight: { type: "number" },
                ShipName: { type: "string" },
                OrderDate: { type: "date" },
                ShipCity: { type: "string" }
            }
        }
    },
    pageSize: 10
});

var grid = $("#grid").kendoGrid({
    dataSource: dts,
    navigatable: true,
    sortable: true,
    audoBind: false,
    height: 240,
    pageable: false,
    scrollable: false,
    columns: [{
        *field: "ShipName",
        width: 100,
        title: "ShipName"
    }, {
        field: "OrderID",
        width: 80,
        title: "OrderID",
        format: "{0:c}"
    }]
}).data("kendoGrid");
dts.read();

另请查看以下链接以获取演示。

http://jsfiddle.net/jayeshgoyani/KZRfV/

于 2013-06-24T13:40:51.773 回答