代码之家  ›  专栏  ›  技术社区  ›  user156888

ExtJS数据视图阵列存储问题

  •  0
  • user156888  · 技术社区  · 16 年前

    我有以下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) {
    
                    }
                }
            }
        })
    });
    

    因此,将数据视图绑定到res.data.similarartist的子数组

    但似乎什么都没发生?

    Preparedata连电话都没有?

    我做错什么了?

    W/

    1 回复  |  直到 16 年前
        1
  •  2
  •   Brian Moeskau    16 年前

    您链接到的数据结构是JSON,而不是数组数据。尝试切换到 JsonStore 相反。请注意,JSONStore预先配置了JSONReader和HTTPProxy(远程数据源),用于从URL加载数据。如果需要从本地数据加载JSON,那么必须使用JSONreader和memoryProxy创建一个通用存储。

    推荐文章