dxSelectBox不会加载数据

时间:2014-11-10 13:56:45

标签: javascript knockout.js phonejs devextreme

根据DevExtreme网站上的演示,我有一个dxSelectBox,但我无法加载数据。代码如下:

<div data-bind="dxSelectBox:{datasource: themes, displayExpr: 'name', valueExpr: 'themeId', value: themeId }"></div>

var themesArray = [
    { themeId: 1, name: "Android (Dunkel)" },
    { themeId: 2, name: "Desktop" },
    { themeId: 3, name: "iOS" },
    { themeId: 4, name: "Windows 8" },
    { themeId: 5, name: "Windows Phone 8" },
    { themeId: 6, name: "Tizen" },
    ];

var themes = new DevExpress.data.DataSource(themesArray);

var viewModel = {
    themes: themes,
    viewShowing: function () {
        this.themes.load();
        },
}

有人可以指出我正确的方向吗?

提前致谢

2 个答案:

答案 0 :(得分:3)

唉...

<div data-bind="dxSelectBox:{datasource

应该用大S读取dataSource

答案 1 :(得分:1)

如果是数组,您可以使用“items”选项并摆脱DataSource创建:

<div data-bind="dxSelectBox: { items: themesArray, ....