【问题标题】:Extjs DataView ArrayStore problemExtjs DataView ArrayStore 问题
【发布时间】:2011-02-24 20:51:54
【问题描述】:

我有以下JS:

http://monobin.com/__m1c171c4e

以及以下代码:

代码:

var tpl = new Ext.XTemplate(
    '<tpl for=".">',
        '<div class="thumb-wrap" id="{Name}">',
        '<div class="thumb"><img src="{ImageMedium}" title="{Name}"></div>',
        '<span class="x-editable">{Name}</span></div>',
    '</tpl>',
    '<div class="x-clear"></div>'
);

var store = new Ext.data.ArrayStore({
    fields: [{ name: 'name' }, { name: 'ImageMedium'}],
    data: res.data.SimilarArtists
});

var panel = new Ext.Panel({
    frame: true,
    width: 535,
    autoHeight: true,
    collapsible: true,
    layout: 'fit',
    title: 'Simple DataView (0 items selected)',
    items: new Ext.DataView({
        store: store,
        tpl: tpl,
        autoHeight: true,
        multiSelect: true,
        overClass: 'x-view-over',
        itemSelector: 'div.thumb-wrap',
        emptyText: 'No images to display',
        prepareData: function (data) {
            data.Name = Ext.util.Format.ellipsis(data.Name, 15);
            return data;
        },

        plugins: [
            new Ext.DataView.DragSelector(),
            new Ext.DataView.LabelEditor({ dataIndex: 'name' })
        ],

        listeners: {
            selectionchange: {
                fn: function (dv, nodes) {

                }
            }
        }
    })
});

所以将 DataView 绑定到 res.data.SimilarArtists 的子数组

但似乎什么也没发生?

prepareData 甚至没有被调用?

我做错了什么?

w://

【问题讨论】:

    标签: extjs dataview


    【解决方案1】:

    您链接到的数据结构是 JSON,而不是数组数据。尝试改用JsonStore。请注意,JsonStore 预配置了 JsonReader 和 HttpProxy(远程数据源),用于从 url 加载数据。如果您需要从本地数据加载 JSON,那么您必须使用 JsonReader 和 MemoryProxy 创建一个通用存储。

    【讨论】:

    • 干杯老兄 - 听起来像那个。我稍后会尝试 iot,但我知道这会奏效 - 昨晚有一个有趣的 5:s
    猜你喜欢
    • 2011-10-30
    • 1970-01-01
    • 2014-10-06
    • 2021-01-11
    • 1970-01-01
    • 2011-08-06
    • 2011-12-22
    • 1970-01-01
    • 2023-04-01
    相关资源
    最近更新 更多