gpt4 book ai didi

extjs - 如何在 Extjs 4.1 中使用 treecombo

转载 作者:行者123 更新时间:2023-12-03 20:59:30 25 4
gpt4 key购买 nike

我在 http://www.sencha.com/forum/showthread.php?198856-Ext.ux.TreeCombo 找到了导师
我尝试在 http://jsfiddle.net/rq2ha/ 中的 Extjs4.1 中制作一个 treecombo
这是我的代码

Ext.onReady(function() {
Ext.create('Ext.ux.TreeCombo', {
margin:10,
width:120,
height: 10,
treeHeight: 10,
treeWidth: 240,
renderTo: 'treecombo3',
store: storeMenu,
selectChildren: false,
canSelectFolders: true
,itemTreeClick: function(view, record, item, index, e, eOpts, treeCombo)
{
var id = record.data.id;
// I want to do something here.
// But combo do nothing (not selected item or not finish) when i init itemTreeClick function
}
});
});

第一个问题:当我单击组合上的树项目时,我想获取树的 id 并执行某些操作。但是当我点击时组合不完整(选择)(组合什么都不做)。
enter image description here

第二个问题:如果我改变商店是动态的
var treestore = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'example.php',
reader: {
type: 'json'
}
},
autoload: true
});

我会得到错误

enter image description here

我的json
[ { id : '1' , text : 'a', iconCls: 'cls1' ,children :[{ id : '2' , text : 'b', iconCls: 'cls2' ,children :[{ id : '9' , text : 'a', iconCls: 'cls' ,children :[]},{ id : '14' , text : 'a', iconCls: 'c' ,children :[{ id : '33' , text : 'b', iconCls: 'cls' ,children :[{ id : '35' , text : 'a', iconCls: 'cls' ,children :[{ id : '36' , text : 'a', iconCls: 'cls' ,children :[]}]}]}]},{ id : '16' , text : 'd', iconCls: 'cls' ,leaf:true}]},...

我该如何解决,谢谢

最佳答案

要解决您的第二个问题,您需要在创建树存储时指定根节点。

var treestore = Ext.create('Ext.data.TreeStore', {
root: {
text: 'Root',
id: '0'
},
proxy: {
type: 'ajax',
url: 'example.php',
reader: {
type: 'json'
}
},
autoload: true
});

另外,我应该提到您在 jsfiddle 示例中用于树存储的变量名称是 storeMenu 而不是 treestore。因此,如果您想用 ajax 版本替换静态树存储,请确保使用正确的变量名称。

关于extjs - 如何在 Extjs 4.1 中使用 treecombo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17718025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com