参考别人的改的
Ext.namespace("Ext.ux.form");
/**
* create by wjc
*/
Ext.ux.form.ComboBoxTree = Ext.extend(Ext.form.ComboBox, {
treeId : Ext.id()+'-tree',
maxHeight :300,
selectedClass : '',
mode : 'local',
triggerAction: 'all',
onSelect : Ext.emptyFn,
editable : false,
//all:所有结点都可选中
//exceptRoot:除根结点,其它结点都可选
//folder:只有目录(非叶子和非根结点)可选
//leaf:只有叶子结点可选
selectNodeModel : 'exceptRoot',
//private
initComponent: function(){
this.initComboBoxTree();
Ext.ux.form.ComboBoxTree.superclass.initComponent.call(this);
},
initComboBoxTree:function(){
this.tpl = new Ext.Template('<tpl for="."><div style="height:'+this.maxHeight+'px"><div id="'+this.treeId+'"></div></div></tpl>');
this.store = new Ext.data.SimpleStore({fields:[],data:[[]]});
if(!this.tree){
var initComboBoxTree_Page =this;
this.tree = new Ext.tree.TreePanel({
loader: new Ext.tree.DWRTreeLoader({
dataUrl:this.DWRfunc,
isteners : {
'beforeload' : function(node) {
initComboBoxTree_Page.getLoader().args[0]=(node.id!='0'?node.id:"1");
}
}
}),
root : new Ext.tree.AsyncTreeNode({
text: this.rootlable,
draggable:false,
id:'1'
})
});
}
},
expand : function(){
Ext.ux.form.ComboBoxTree.superclass.expand.call(this);
if(!this.tree.rendered){
this.tree.height = this.maxHeight;
this.tree.border=false;
this.tree.autoScroll=true;
if(this.tree.xtype){
this.tree = Ext.ComponentMgr.create(this.tree, this.tree.xtype);
}
this.tree.render(this.treeId);
var combox = this;
this.tree.on('click',function(node){
var isRoot = (node == combox.tree.getRootNode());
var selModel = combox.selectNodeModel;
var isLeaf = node.isLeaf();
if(isRoot && selModel != 'all'){
return;
}else if(selModel=='folder' && isLeaf){
return;
}else if(selModel=='leaf' && !isLeaf){
return;
}
combox.setValue(node);
combox.collapse();
});
var root = this.tree.getRootNode();
if(!root.isLoaded())
root.reload();
}
},
setValue : function(node){
var text = node;
if(node.text)
text = node.text;
if(this.valueField){
var r = this.findRecord(this.valueField, node.text);
if(r){
text = r.data[this.displayField];
}else if(Ext.isDefined(this.valueNotFoundText)){
text = this.valueNotFoundText;
}
}
this.lastSelectionText = text;
if(this.hiddenField){
this.hiddenField.value = node.text;
}
Ext.ux.form.ComboBoxTree.superclass.setValue.call(this, text);
this.value = node.text;
return this;
},
getValue : function(){
return typeof this.value != 'undefined' ? this.value : Ext.ux.form.ComboBoxTree.superclass.getValue.call(this);
}
});
Ext.reg('combotree', Ext.ux.form.ComboBoxTree);

- 大小: 24.3 KB
分享到:
相关推荐
`ComboBoxTree`就是一个很好的例子,它将传统的`ComboBox`与`TreeView`控件的功能结合在一起,为用户提供了一种在下拉列表中以树形结构展示数据的新方式。这个组件是由非官方的开发者设计的,目的是解决在有限的空间...
在这个特定的情况下,我们讨论的是一个定制的下拉树菜单控件——ComboBoxTree,它在ExtJS4中实现了单选和多选功能,并且具备展开选中指定节点的能力。这个控件在实际项目中已经被广泛使用并证明了其稳定性和实用性,...
在ExtJS 4.x框架中,ComboboxTree是一种特殊的组件,它将传统的下拉框与树形结构结合在一起,提供了一种更为灵活的用户输入方式。这种组件在数据选择上非常实用,尤其当数据层级关系复杂时,可以方便地进行多选或...
然而,当需求不仅仅是简单的文本选择,而是需要层级结构的数据展示时,比如树形结构,这时就出现了ComboBoxTree——一个结合了下拉框和树形结构的组件。 在ExtJS的ComboBoxTree实现中,它通常包含以下关键特性: 1...
《ComboBoxTree.js:JavaScript中的下拉树控件详解》 ComboBoxTree.js,作为一个常见的JavaScript库,主要用于在Web应用中实现一种结合了下拉框和树形结构的控件。这种控件融合了下拉列表的选择功能与树形结构的...
【Ext 3.x + Ext 2.x 下拉树 Ext.ux.ComboBoxTree】是基于ExtJS框架的一个组件,它结合了下拉框(ComboBox)和树形控件(TreePanel)的功能,提供了一种用户友好的选择界面。在网页应用中,这种控件常用于展示层级...
EXT COMBOBOXTREE 下拉框树
用Div和TreeView模拟的下拉框树. 并解决了Select总在最顶端的问题,即下拉框中的树不被Select控件遮盖 用c# + asp.net 2.0实现 ComboBoxTreeCtrl.ascx为自定义下拉树控件 Default.aspx为例子页面
ComboBoxTree控件是一种在Web应用中常见的UI组件,它结合了ComboBox(下拉框)和TreeView(树形视图)的功能,提供了一种更灵活、更直观的数据选择方式。在.NET框架中,我们可以使用自定义控件或者第三方库来实现...
带复选框的这是经过测试可以用的下拉树
menu.json json格式数据,模拟从后台返回的json数据 PinyinFilter.js:提供进行拼音过滤所需要的函数 TreeFilter.js:自定义的类,提供树结点的过滤功能(依赖于PinyinFilter.js) JsonTreeLoader.js:自定义的...
本项目“ComboBoxTree.rar”专注于一个特定的UI控件实现,即在传统的下拉组合框(ComboBox)中嵌入树视图(TreeView)的功能。这样的设计可以提供更丰富的交互体验,允许用户在一个紧凑的空间里浏览和选择层次结构的...
标题中的"ext comboboxtree"可能指的是EXTJS框架中的一个组件,ComboboxTree。EXTJS是一个用JavaScript编写的富客户端应用开发框架,它提供了一系列的可重用UI组件,如表格、树形控件、组合框等。ComboboxTree是这个...
在ExtJS中,为了实现一个具有下拉树结构的ComboBox,即ComboBoxTree,通常需要自定义组件,因为原生的ExtJS库并不直接提供这样的功能。以下是对标题和描述中所述知识点的详细解释: 1. **自定义组件**: 在ExtJS中...