2

我是剑道 UI 框架的新手。我正在使用 kendoGrid 处理可观察的数据源。问题是表已创建但数据为空。这是链接http://jsfiddle.net/praveeny1986/Pf3TQ/5/

和代码:

var gridDataModel = kendo.data.Model.define({
fields: {
    "Product": {
        type: "string"
    },
    "Domain": {
        type: "string"
    },
    "PercentPlan": {
        type: "string"
    },
    "CWV": {
        type: "string"
    },
    "Target": {
        type: "string"
    },
    "Accuracy": {
        type: "string"
    }
}
});

var dataSource = new kendo.data.DataSource({data: tabledata1});

var gridModel = kendo.observable({
    gridData: dataSource
});
kendo.bind($("#chart"),gridModel);
$("#chart").kendoGrid({
    scrollable:false,
dataSource:gridModel.get('gridData'),
    height:600,
    autoBind:true,
    columns:[
        {
            field: "Product",
            title: "Product"
        },
        {
            field: "Domain",
            title: "Sales Domain"
        },
        {
            field: "PercentPlan",
            title: "% to Plan"
        },
        {
            field: "CWV",
            title: "CWV"
        },
        {
            field: "Target",
            title: "Target"
        },
        {
            field: "Accuracy",
            title: "Accuracy"
        }]
});
var tabledata1 = [
{
    Product:"mobile",
    Domain:"SMARTPHONES-EAST",
    PercentPlan:"95",
    CWV:"160",
    Target:"200",
    Accuracy:"9"
},
{
    Product:"mobile",
    Domain:2,
    PercentPlan:"80",
    CWV:"160",
    Target:"200",
    Accuracy:"8.5"
},
{
    Product:"mobile",
    Domain:3,
    PercentPlan:"75",
    CWV:"150",
    Target:"200",
    Accuracy:"8"
},
{
    Product:"mobile",
    Domain:4,
    PercentPlan:"60",
    CWV:"120",
    Target:"200",
    Accuracy:"6"
},
{
    Product:"mobile",
    Domain:5,
    PercentPlan:"50",
    CWV:"150",
    Target:"300",
    Accuracy:"5"
}
];

请建议我做错了什么?

提前致谢

4

1 回答 1

3

在您创建和绑定数据源时,您的表数据是未定义的。

var dataSource = new kendo.data.DataSource({data: tabledata1});
var tabledata1 = [ ... ];

将 tabledata1 的声明移到创建数据源之前。看到这个更新的小提琴。

http://jsfiddle.net/nukefusion/Pf3TQ/7/

于 2013-02-28T14:08:26.260 回答