【问题标题】:extjs: load tree via json returned from Ext.data.JsonStoreextjs:通过从 Ext.data.JsonStore 返回的 json 加载树
【发布时间】:2011-04-19 21:33:31
【问题描述】:

我有一个 extjs TreePanel,我需要使用从 Ext.data.JsonStore 调用返回的 json 数据(跨域调用)加载它。这完美无缺。我只是找不到使用返回的 jsonStore 加载树形面板的方法。有任何想法吗?我是真正的亡命之徒。

谢谢大家!

代码sn-p:

var store = new Ext.data.JsonStore({
    root: 'topics',
    totalProperty: 'totalCount',
    idProperty: 'threadid',
    remoteSort: true,

    fields: [
        'title', 'forumtitle', 'forumid', 'author',
        {name: 'replycount', type: 'int'},
        {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
        'lastposter', 'excerpt'
    ],

    proxy: new Ext.data.ScriptTagProxy({
        url: 'http://other.domain/test.aspx'
    })
});

// 现在我需要使用该存储来加载树...

var Tree = Ext.tree;
var tree = new Tree.TreePanel({
  useArrows: true,
  autoScroll: true,
  animate: true,
  enableDD: true,
  containerScroll: true,
  border: false,
  loader: new Tree.TreeLoader({ dataUrl: '????' })
  //.....
});

救命!

【问题讨论】:

    标签: json extjs tree cross-domain


    【解决方案1】:

    您必须向存储添加负载侦听器并手动将加载数据中的树节点添加到树中,树不直接支持存储,请记住树是分层的,并且存储非常平坦。

    【讨论】:

    • 嘿劳埃德 - 我喜欢迅速的反应。任何可以帮助我的代码 sn-p 或 url 的机会?
    猜你喜欢
    • 1970-01-01
    • 2012-07-16
    • 1970-01-01
    • 2012-02-27
    • 1970-01-01
    • 2013-05-24
    • 1970-01-01
    • 1970-01-01
    • 2013-04-03
    相关资源
    最近更新 更多