1

根据 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();
        },
}

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

提前致谢

4

2 回答 2

3

叹...

<div data-bind="dxSelectBox:{datasource

那应该读dataSource大S

于 2014-11-10T14:40:05.497 回答
1

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

<div data-bind="dxSelectBox: { items: themesArray, ....
于 2014-11-11T11:35:55.900 回答