如何在EXTJS中构建树? [英] how to build tree in EXTJS?

查看:283
本文介绍了如何在EXTJS中构建树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在EXTJS中构建树?它必须包含相应节点的图像(带有'+'和' - '符号)。可以让我得到相同的代码?

How to build a tree in EXTJS ? It has to include the images(with '+' & '-' symbols) with respective node.Can you get me the code for the same ????

推荐答案

首先定义一个Ext.data.TreeStore将您的数据加载到:

var store = Ext.create('Ext.data.TreeStore', {
    proxy: {
        type: 'ajax',
        url: 'treeData.json'
    },
    root: {
        text: 'Countries',
        expanded: true
    }
});

Json:

[{
"text": "United Kindom",
"children": [{
    "text": "Glasgow",
    "leaf": true
}, {
    "text": "Edinburgh",
    "leaf": true
}, {
    "text": "London",
    "leaf": true
}],
"leaf": false
},
{
    "text": "France",
    "leaf": true
}
...
]

创建树面板并将其渲染到文档的正文:

Ext.create('Ext.tree.Panel', {
    title: 'Countries & Cities',
    width: 500,
    height: 300,
    store: store,
    useArrows: false,
    rootVisible: false,
    renderTo: Ext.getBody(),
    style: 'margin: 50px'
});

这篇关于如何在EXTJS中构建树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆