解决 Ext3.x 中 ComboboxTree 展开树时panel被关闭的bug
2011-11-21 23:10
337 查看
解决办法, 把ComboboxTree.js代码换成下面的:
Ext.form.ComboBoxTree = Ext.extend(Ext.form.ComboBox, {
store: new Ext.data.SimpleStore({ fields: [], data: [[]] }),
editable: false,
shadow: false,
mode: 'local',
triggerAction: 'all',
selectedClass: '',
onSelect: null,
canCollapse: true,
constructor: function(_cfg) {
if (_cfg == null) {
_cfg = {};
}
Ext.apply(this, _cfg);
this.treerenderid = Ext.id();
this.tpl = String.format('<tpl for="."><div style="height:200px"><div id="ext-combobox-tree{0}"></div></div></tpl>', this.treerenderid);
Ext.form.ComboBoxTree.superclass.constructor.apply(this, arguments);
if (this.tree) {
var cmb = this;
this.tree.on('click', function(node) {
cmb.canCollapse = true;
if (Ext.isFunction(cmb.onSelect)) {
cmb.onSelect(cmb, node);
} else {
cmb.setValue(node.text);
if (cmb.hiddenField) {
cmb.hiddenField.value = node.id;
}
}
cmb.collapse();
});
//以下事件,让combobox能正常关闭
this.tree.on('expandnode', function() { cmb.canCollapse = true; });
this.tree.on('beforeload', function() { cmb.canCollapse = false; });
this.tree.on('beforeexpandnode', function() { cmb.canCollapse = false; });
this.tree.on('beforecollapsenode', function() { cmb.canCollapse = false; });
}
this.on('expand', this.expandHandler, this);
this.on('collapse', this.collapseHandler, this);
},
expandHandler: function expand() {
this.canCollapse = true;
if (this.tree) {
this.tree.render('ext-combobox-tree' + this.treerenderid);
this.canCollapse = true;
this.tree.getRootNode().expand();
}
},
collapseHandler: function collapse() {
if (!this.canCollapse) {
this.expand();
}
}
});
Ext.reg('combotree', Ext.form.ComboBoxTree);
调用代码:
new Ext.form.ComboBoxTree({
id: 'mytree',
hiddenName:'dept_no',
fieldLabel:'机构',
tree: new Ext.tree.TreePanel({
root: new Ext.tree.AsyncTreeNode({ text: '--选择--', id: '0' }),
rootVisible: false,
border: false,
dataUrl: '/AreaList.aspx',
listeners: {
beforeload: function(n) { if (n) { this.getLoader().baseParams.id = n.attributes.id; } }
}
})/*,
onSelect: function(cmb, node) {
alert(node.attributes.text);
}*/
})
Ext.form.ComboBoxTree = Ext.extend(Ext.form.ComboBox, {
store: new Ext.data.SimpleStore({ fields: [], data: [[]] }),
editable: false,
shadow: false,
mode: 'local',
triggerAction: 'all',
selectedClass: '',
onSelect: null,
canCollapse: true,
constructor: function(_cfg) {
if (_cfg == null) {
_cfg = {};
}
Ext.apply(this, _cfg);
this.treerenderid = Ext.id();
this.tpl = String.format('<tpl for="."><div style="height:200px"><div id="ext-combobox-tree{0}"></div></div></tpl>', this.treerenderid);
Ext.form.ComboBoxTree.superclass.constructor.apply(this, arguments);
if (this.tree) {
var cmb = this;
this.tree.on('click', function(node) {
cmb.canCollapse = true;
if (Ext.isFunction(cmb.onSelect)) {
cmb.onSelect(cmb, node);
} else {
cmb.setValue(node.text);
if (cmb.hiddenField) {
cmb.hiddenField.value = node.id;
}
}
cmb.collapse();
});
//以下事件,让combobox能正常关闭
this.tree.on('expandnode', function() { cmb.canCollapse = true; });
this.tree.on('beforeload', function() { cmb.canCollapse = false; });
this.tree.on('beforeexpandnode', function() { cmb.canCollapse = false; });
this.tree.on('beforecollapsenode', function() { cmb.canCollapse = false; });
}
this.on('expand', this.expandHandler, this);
this.on('collapse', this.collapseHandler, this);
},
expandHandler: function expand() {
this.canCollapse = true;
if (this.tree) {
this.tree.render('ext-combobox-tree' + this.treerenderid);
this.canCollapse = true;
this.tree.getRootNode().expand();
}
},
collapseHandler: function collapse() {
if (!this.canCollapse) {
this.expand();
}
}
});
Ext.reg('combotree', Ext.form.ComboBoxTree);
调用代码:
new Ext.form.ComboBoxTree({
id: 'mytree',
hiddenName:'dept_no',
fieldLabel:'机构',
tree: new Ext.tree.TreePanel({
root: new Ext.tree.AsyncTreeNode({ text: '--选择--', id: '0' }),
rootVisible: false,
border: false,
dataUrl: '/AreaList.aspx',
listeners: {
beforeload: function(n) { if (n) { this.getLoader().baseParams.id = n.attributes.id; } }
}
})/*,
onSelect: function(cmb, node) {
alert(node.attributes.text);
}*/
})
相关文章推荐
- 解决 Ext3.x 中 ComboboxTree 展开树时panel被关闭的bug
- 解决WinForm中ComboBox没有value值的bug
- 编写Extjs treepanel的节点展开事件
- Extjs6 treepanel store无法加载请求后台URL数据bug
- delphi TreeComboBox 解决树的单击事件和小三角单击事件冲突问题
- ExtJs TreePanel使用TreeLoader在IE下无法正常加载显示的解决方法
- Extjs6 treepanel 自动靠右bug
- extjs TreePanel 加载数据后默认选中第一个孩子并展开子级
- datagrid可编辑表格使用Combobox多选编辑时无法选择、新增时无法保存BUG解决
- 解决了coolite官方示例"TreePanel/basic/refresh static tree"的一个错误
- Easyui - combo[tree,box]下拉图标有间隙bug解决方法
- Extjs treePanel中节点展开在关闭时出现重复数据
- Flex3.5 bug: 改变ComboBox DataProvider后UI不更新的初步解决
- 对 COMBOBOX 的外科手术:解决 COMBOBOX 处理回退键的 BUG
- [ExtJS4]ExtJS4左边菜单面板收缩展开,右边TabPanel内容动态更新(解决宽度不能自适应问题)
- extjs4 treepanel checkbox 复选框 全选完美解决
- Asp.net UpdatePanel在asyncpostback后页面标题丢失的BUG解决
- ux.form.field.TreePicker 扩展,修复火狐不能展开bug
- 解决Ext 4.0.7 tree.Panel横向不出滚动条,纵向滚动条失效的问题
- 导航面板[ExtJS4]ExtJS4左边菜单面板收缩展开,右边TabPanel内容动态更新(解决宽度不能自适应问题)