Ext中comboBox跟TreePanel实现下拉树,关键点就是:下拉之前要先清空树的div ,然后在render上去,如:el = el.parent().dom.innerHTML="";
//start 扩展combobox+treepanel组合
var el = Ext.get("tree");
if(el){
el = el.parent().dom.innerHTML=""; //清空之前树的div
}
var comboxWithTree = new Ext.form.ComboBox({
store:new Ext.data.SimpleStore({fields:[],data:[[]]}),
editable:false,
mode: 'local',
triggerAction:'all',
maxHeight: 200,
tpl: "",
selectedClass:'',
onSelect:Ext.emptyFn
});
var tree = new Ext.tree.TreePanel({
loader: new Ext.tree.TreeLoader({
dataUrl : getAppName()+'/faq/faq_faq/util_faq/getFaqTypeTree.jsp'
}),
border:false,
root:new Ext.tree.AsyncTreeNode({id:'0',text: 'FAQ类型'})
});
tree.on('click',function(node,e){
if ( node.id =='0') {
e.stopEvent();// 如果是根节点则不触发
return;
}
comboxWithTree.setValue(node.text);
comboxWithTree.collapse(); // 隐藏ComboBox列表
});
comboxWithTree.on('expand',function(){
tree.render('tree');
});
comboxWithTree.render('faq_functree_idDiv');
//end 扩展combobox+treepanel组合