extjs tree下拉列表_Ext TreeCombo 树形 下拉框

参考:http://www.extjs.com/forum/showthread.php?38654-Tree-in-a-Combo./page4

在别人基础上稍作修改

1.添加hiddenName,使传值时跟Ext.form.ComboBox类似;

2.设值时展开整棵树(在TreeCombo外实现),使弹出下拉框时默认选中节点;

代码如下:

/**

* @version Base on Ext3.0

* @class Ext.ux.TreeCombo

* @extends Ext.form.TriggerField

*/

Ext.ux.TreeCombo = Ext.extend(Ext.form.TriggerField, {

// triggerClass: 'x-form-tree-trigger',

initComponent : function() {

this.readOnly = true;

Ext.ux.TreeCombo.superclass.initComponent.call(this);

this.on('specialkey', function(f, e) {

if (e.getKey() == e.ENTER) {

this.onTriggerClick();

}

}, this);

this.getTree();

},

onTriggerClick : function() {

this.getTree().show();

this.getTree().getEl().alignTo(this.wrap, 'tl-bl?');

},

getTree : function() {

if (!this.treePanel) {

if (!this.treeWidth) {

this.treeWidth = Math.max(150, this.width || 200);

}

if (!this.treeHeight) {

this.treeHeight = 200;

}

this.treePanel = new Ext.tree.TreePanel({

renderTo : Ext.getBody(),

loader : this.loader || new Ext.tree.TreeLoader({

preloadChildren : (typeof this.root == 'undefined'),

url : this.dataUrl || this.url

}),

root : this.root || new Ext.tree.AsyncTreeNode({

children : this.children

}),

rootVisible : (typeof this.rootVisible != 'undefined')

? this.rootVisible

: (this.root ? true : false),

floating : true,

autoScroll : true,

minWidth : 200,

minHeight : 200,

width : this.treeWidth,

height : this.treeHeight,

listeners : {

hide : this.onTreeHide,

show : this.onTreeShow,

click : this.onTreeNodeClick,

expandnode : this.onExpandOrCollapseNode,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值