扩展extjs ComboBoxTree组件
来源:互联网 发布:淘宝怎么联系卖家电话 编辑:程序博客网 时间:2024/06/10 06:34
/** * Created by QC on 2017/3/30. */// 封装的ComboBoxTree组件ComboBoxTree = Ext.extend(Ext.form.ComboBox, { fieldLabel : 'ComboBoxTree',// 标题名称 baseUrl : null, emptyText : null, maxHeight : 300, treeId : Ext.id() + '-tree', tree : null, // all:所有结点都可选中 // exceptRoot:除根结点,其它结点都可选(默认) // folder:只有目录(非叶子和非根结点)可选 // leaf:只有叶子结点可选 selectNodeModel : 'exceptRoot', initComponent : function() { var resultTpl = new Ext.XTemplate('<tpl for="."><div style="height:' + this.maxHeight + 'px"><div id="' + this.treeId + '"></div></div></tpl>'); this.addEvents('afterchange'); Ext.apply(this, { fieldLabel : this.fieldLabel, anchor : '100%', emptyText : this.emptyText || '请选择', forceSelection : true, selectedClass : '', // 值为true时将限定选中的值为列表中的值, // 值为false则允许用户将任意文本设置到字段(默认为false)。 selectOnFocus : true, // 值为 ture时表示字段获取焦点时自动选择字段既有文本(默认为false)。 mode : 'local', store : new Ext.data.SimpleStore({ fields : [], data : [[]] }), editable : false,// 是否编辑 triggerAction : 'all', typeAhead : false, tpl : resultTpl, onSelect : Ext.emptyFn() }); ComboBoxTree.superclass.initComponent.call(this); }, expand : function() { ComboBoxTree.superclass.expand.call(this); if (this.tree.rendered) { return; } Ext.apply(this.tree, { height : this.maxHeight, border : false, autoScroll : true }); if (this.tree.xtype) { this.tree = Ext.ComponentMgr.create(this.tree, this.tree.xtype); } this.tree.render(this.treeId); var root = this.tree.getRootNode(); if (!root.isLoaded()) { root.reload(); } this.tree.on('click', function(node) { var selModel = this.selectNodeModel; var isLeaf = node.isLeaf(); if ((node == root) && selModel != 'all') { return; } else if (selModel == 'folder' && isLeaf) { return; } else if (selModel == 'leaf' && !isLeaf) { return; } var oldNode = this.getNode(); if (this.fireEvent('beforeselect', this, node, oldNode) !== false) { this.setValue(node); this.collapse(); this.fireEvent('select', this, node, oldNode); (oldNode !== node) ? this.fireEvent('afterchange', this, node, oldNode) : ''; } }, this); this.tree.expandAll(); }, setValue : function(node) { this.node = 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 : ''; }, getNode : function() { return this.node; }, clearValue : function() { ComboBoxTree.superclass.clearValue.call(this); this.node = null; }, // private destroy : function() { ComboBoxTree.superclass.destroy.call(this); Ext.destroy([this.node, this.tree]); delete this.node; }});//应用:/*var cboTree = new ComboBoxTree({ renderTo : 'comboBoxTree', width : 200, tree : { xtype:'treepanel', loader: new Ext.tree.TreeLoader({dataUrl:'treedata.json'}), root : new Ext.tree.AsyncTreeNode({id:'0',text:'根结点'}) }, //all:所有结点都可选中 //exceptRoot:除根结点,其它结点都可选(默认) //folder:只有目录(非叶子和非根结点)可选 //leaf:只有叶子结点可选 selectNodeModel:'leaf'}); */
0 0
- 扩展extjs ComboBoxTree组件
- Extjs comboboxtree
- Extjs中ComboBoxTree的实现
- 扩展/自定义 Extjs.Toolbar 组件
- 扩展/自定义 Extjs.Toolbar 组件
- ComboBoxTree
- ExtJS 4 组件扩展(一)
- ExtJS 组件的扩展和继承
- ExtJS 组件的扩展和继承
- ExtJS 组件扩展 组件化编程 扩展组件 组件编程(二)
- ExtJS Form扩展组件[ColorFiled, DateTimeFiled, IconCombo, MultiComboBox, DynamicTreeCombox]
- ExtJS 组件的扩展和继承(一)
- Extjs扩展flash播放组件,兼容IE,FF
- 一份完整的Spring+Hibernate+DWR+extJs的生成树及下拉comBoboxTree
- ComboBoxTree源码
- extjs扩展组件还是写插件(Manual:Component:Extension or Plugin )
- ExtJs4.2应用:使用ExtJs扩展组件searchfield实现数据搜索功能
- ExtJsExtenderControl,ExtJs扩展控件
- 3月份月报总结
- Linux nc 命令 【转】
- 我是一个网卡
- mybatis中常用的的jdbcType类型
- Spring AOP-通知-前置通知
- 扩展extjs ComboBoxTree组件
- 我是一个路由器
- 迭代器模式
- 将一个正整数分解质因数
- MySQL没有row_number()问题解决方案
- 深入分析理解session与cookie的作用
- java中自定义注解并通过反射获取注解属性值
- MFC--控制多线程,开启、暂停、继续、终止
- 一步解决 android studio 编译慢的烦恼