参考别人的改的
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
分享到:
相关推荐
Extjs4 comboboxTree下拉树型菜单,完美支持多选、单选,绝对好用。来源于网络,稍作修改。
Extjs4下拉树菜单 ComboBoxTree 支持单选和多选并且支持展开选中指定节点的通用控件 在项目中已经成熟运用 值得收藏和运用
是国外的人员开发的ComboBoxTree,在ComboBox的选项中以tree的形式展现出来。
EXT COMBOBOXTREE 下拉框树
ComboBoxTree.jsComboBoxTree.jsComboBoxTree.jsComboBoxTree.jsComboBoxTree.jsComboBoxTree.js
[Ext 3.x + Ext 2.x] 下拉树 Ext.ux.ComboBoxTree
extjs下拉树,在网上找了很多,发现bug实在让人头大,干脆自己写了个下拉树组件,功能全面
用Div和TreeView模拟的下拉框树. 并解决了Select总在最顶端的问题,即下拉框中的树不被Select控件遮盖 用c# + asp.net 2.0实现 ComboBoxTreeCtrl.ascx为自定义下拉树控件 Default.aspx为例子页面
带复选框的这是经过测试可以用的下拉树
最近涉及到的一个项目中,需要实现ComboBoxTree的效果,首先,看看效果吧…… 在Extjs中是没有这种效果的,所以得自己写,在网络上看了看别人的资料,自己再总结了一下,修改了一下,代码如下: 代码如下: Ext.ux....
menu.json json格式数据,模拟从后台返回的json数据 PinyinFilter.js:提供进行拼音过滤所需要的函数 TreeFilter.js:自定义的类,提供树结点的过滤功能(依赖于PinyinFilter.js) JsonTreeLoader.js:自定义的...
详细介绍见个人博客; http://blog.csdn.net/piaolingzxh/archive/2011/03/23/6270688.aspx
C#源代码,在下拉组合框(ComboBox)中显示树视图(TreeView)