这个是我用他的,不知道我有没有改过,我是在3.0环境下可以正常使用
[code="js"]
Ext.ux.ComboBoxTree = function() {
this.treeId = Ext.id() + '-tree';
this.maxHeight = arguments[0].maxHeight || arguments[0].height || this.maxHeight;
this.maxWidth = arguments[0].maxWidth || arguments[0].width || this.maxWidth;
this.tpl = new Ext.Template('
');
this.store = new Ext.data.SimpleStore({
fields : [],
data : [[]]
});
this.selectedClass = '';
this.mode = 'local';
this.triggerAction = 'all';
this.onSelect = Ext.emptyFn;
this.editable = false;
// all:所有结点都可选中
// exceptRoot:除根结点,其它结点都可选
// folder:只有目录(非叶子和非根结点)可选
// leaf:只有叶子结点可选
this.selectNodeModel = arguments[0].selectNodeModel || 'exceptRoot';
Ext.ux.ComboBoxTree.superclass.constructor.apply(this, arguments);
}
Ext.extend(Ext.ux.ComboBoxTree, Ext.form.ComboBox, {
expand : function() {
Ext.ux.ComboBoxTree.superclass.expand.call(this);
if (!this.tree.rendered) {
this.tree.height = this.maxHeight;
this.tree.width = this.maxWidth;
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.text;
this.lastSelectionText = text;
if (this.hiddenField) {
this.hiddenField.value = node.id;
}
Ext.form.ComboBox.superclass.setValue.call(this, text);
this.value = node.id;
},
getValue : function() {
return typeof this.value != 'undefined' ? this.value : '';
}
});
Ext.reg('combotree', Ext.ux.ComboBoxTree);
[/code]
我是这样使用的,不知道和你的有什么区别
[code="js"]
{
fieldLabel : '模块',
xtype : 'combotree',
name : 'module',
hiddenName : 'question.module',
allowBlank : false,
blankText : '必须选择模块!',
selectNodeModel : 'leaf',
emptyText : '请选择...',
tree : {
xtype : 'treepanel',
rootVisible : false,
loader : new Ext.tree.TreeLoader({
preloadChildren : true,
clearOnLoad : false
}),
root : new Ext.tree.AsyncTreeNode({
text : '根结点',
expanded : true,
children : Ext.help.treeData
})
}
}
[/code]