当前位置: 代码迷 >> Web前端 >> 扩展combo上拉树
  详细解决方案

扩展combo上拉树

热度:113   发布时间:2012-11-01 11:11:31.0
扩展combo下拉树

Ext.TreeComboflh = Ext.extend(Ext.form.ComboBox, {
??initList : function() {
???this.list = new Ext.tree.TreePanel({
????autoScroll : true,
????resizable : true,
????rootVisible : false,
????root : new Ext.tree.AsyncTreeNode({
???????id : '',
???????text : '根节点'
??????}),
????loader : new Ext.tree.TreeLoader({
?????dataUrl :?this.dataUrl
?????????}),
????floating : true,
????height : 300,
????width : 80,
????listeners : {
?????click : this.onNodeClick,
?????scope : this
????},
????alignTo : function(el, pos) {
?????this.setPagePosition(this.el.getAlignToXY(el, pos));
????}
???});
??},
??expand : function() {
???if (!this.list.rendered) {
????this.list.render(document.body);
????this.list.setWidth(this.el.getWidth());
????this.innerList = this.list.body;
????this.list.hide();
???}
???this.el.focus();
???Ext.TreeComboflh.superclass.expand.apply(this, arguments);
??},
??doQuery : function(q, forceAll) {
???this.expand();
??},
??collapseIf : function(e) {
???if (!e.within(this.wrap) && !e.within(this.list.el)) {
????this.collapse();
???}
??},
??onNodeClick : function(node, e) {
???if (node.attributes.description != null
?????&& node.attributes.description != '') {
????this.setValue(node.attributes.description);
????this.setRawValue(node.attributes.text);
???} else {
????this.setValue(node.id);
????this.setRawValue(node.attributes.text);
???}
???this.collapse();
??}
?});
?Ext.reg('treecomboflh', Ext.TreeComboflh);