【问题标题】:Kendo Datasource "e is undefined" error剑道数据源“e未定义”错误
【发布时间】:2016-06-01 10:10:29
【问题描述】:

在 Telerik Kendo UI 2016 Q2 我想创建数据源:

var dat1 = '{"items":[{ name: "Pork", category: "Food", subcategory: "Meat" },{ name: "Pepper", category: "Food", subcategory: "Vegetables" },{ name: "Beef", category: "Food", subcategory: "Meat" }]}';
var dataSource = new kendo.data.DataSource({
    data: dat1,
    dataType: "json",
    schema: {
        data: "items"
    }
});
dataSource.fetch(function () {
});

但我在 firefox/firebug 中遇到了这个错误

类型错误:e 未定义

我知道错误是针对"schema: {data:"items"}"

也将 dataType 更改为 jsonp 并有相同的错误。

【问题讨论】:

  • 获取时会发生这种情况吗?尝试为数据源添加模型或尝试使用datasource.read()
  • 为什么要将 dat1 设置为字符串?

标签: kendo-ui datasource


【解决方案1】:

尝试使用:

schema: {
data: function(response) {
  return response.items; }
}

然后在调试器中观察导致该错误的原因

dat1 也是一个字符串,使用JSON.parse 从中创建 JSON

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-21
    • 2013-10-29
    • 2016-08-18
    相关资源
    最近更新 更多