首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Extjs DataView ArrayStore问题

Extjs DataView ArrayStore问题
EN

Stack Overflow用户
提问于 2010-05-28 04:43:41
回答 1查看 4.3K关注 0票数 0

我有以下JS:

http://monobin.com/__m1c171c4e

和以下代码:

代码:

代码语言:javascript
复制
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://

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-05-28 07:51:08

您链接到的数据结构是JSON,而不是数组数据。请尝试切换到JsonStore。注意,JsonStore预先配置有JsonReader和HttpProxy (远程数据源),并且用于从url加载数据。如果需要从本地数据加载JSON,则必须创建一个具有JsonReader和MemoryProxy的泛型存储区。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2924766

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档