Ext-combobox-tree的运用
来源:互联网 发布:淘宝客开源 编辑:程序博客网 时间:2024/05/04 18:02
前几天研究了combobox-tree,把自己一点心得发出来
自己定义一个combobox
Ext.ux.form.TreeComboBox = Ext.extend(Ext.form.ComboBox, {
initComponent : function(ct, position) {
this.divId = 'tree-' + Ext.id();
if (isNaN(this.maxHeight))
this.maxHeight = 200;
Ext.apply(this, {
tpl : '<tpl>' + '<div style="height:' + this.maxHeight + 'px;">' + '<div id="' + this.divId + '"></div>' + '</div></tpl>'
});
//tree的节点
var root = new Ext.tree.AsyncTreeNode({
text : this.rootText,
id : this.rootId,
draggable : false,
autoHeight : true,
autoScroll : true,
//这里注意下,我的数据是下面setData的,加载页面就传进来了
// loader : new Ext.tree.TreeLoader({
// dataUrl : this.treeUrl,
// clearOnLoad : true
// })
});
//一个tree
this.tree = new Ext.tree.TreePanel({
border : false,
root : root,
rootVisible : this.rootVisible,
listeners : {
scope : this,
click : function(node) {
this.setValue(node);
this.collapse();
}
}
});
//加载数据
root.setData(initData.goodTreeData);
//判断选择的是否是节点
this.tree.on('click',this.onViewClick,this);
//继承父类的构造函数
Ext.ux.form.TreeComboBox.superclass.initComponent.call(this);
},
onRender : function(ct, position) {
//继承父类的Onrender展开
Ext.ux.form.TreeComboBox.superclass.onRender.call(this, ct, position);
//默认展开
this.on("expand", function() {
if (!this.tree.rendered) {
this.tree.render(this.divId);
this.tree.expandAll();
}
}, this)
},
onViewClick : function(doFocus){
if(doFocus !== false){
this.el.focus();
}
}
});
Ext.reg('uxtreecombobox', Ext.ux.form.TreeComboBox);
//重新定下下setValue方法
Ext.override(Ext.form.ComboBox, {
setValue : function(node) {
if (typeof node == "object") {
// 当node为object对象时 node和tree里面的对应
this.lastSelectionText = node.text;
// 设置显示文本为node的text
this.setRawValue(node.text);
if (this.hiddenField) {
// 设置隐藏值为node的id
this.hiddenField.value = node.id;
}
this.value = node.id;
return this;
} else {
// 当node为文本时
var text = node;
if (this.valueField) {
var r = this.findRecord(this.valueField, node);
if (r) {
text = r.data[this.displayField];
} else if (Ext.isDefined(this.valueNotFoundText)) {
text = this.valueNotFoundText;
}
}
this.lastSelectionText = text;
if (this.hiddenField) {
this.hiddenField.value = node;
}
Ext.form.ComboBox.superclass.setValue.call(this, text);
this.value = node;
return this;
}
}
});
js代码
xtype : 'uxtreecombobox',
id : 'lgtid',
hiddenName : 'name',
editable : false,
store : lgtidStore,
shadow : true,
mode : 'local',
displayField : 'name',
valueField : 'lgtid',
triggerAction : 'all',
allowBlank : false,
forceSelection : true,
maxHeight : 150,
autoHeight : true,
listeners : {
specialkey : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
reloadDepotInDs()
}
}
}
- Ext-combobox-tree的运用
- Ext.net Combobox +Tree
- Ext Combobox的应用
- Ext的combobox案例
- 关于ComboBox的运用
- Ext combobox 的动态改变
- Ext ComboBox 默认值的设置
- Extjs的Ext.form.ComboBox
- ext.net combobox 的初始化
- ext.form.combobox的联动
- Ext,ComboBox
- Ext的tree
- Ext tree的属性
- Ext.form.ComboBox 实现两个ComboBox 的相互级联
- 扩展的带图片的Ext combobox
- Ext的combobox的fieldlabel不显示
- EXT-ComboBox的两种用法
- 关于 Ext.form.ComboBox的模糊过滤
- 第14周报告1 用递归函数求解表达式
- html frameset中的frame添加背景色
- java堆栈区别
- 第14周报告2:计算小组的成绩
- struts标签<s:date>的使用
- Ext-combobox-tree的运用
- ”一个封锁操作被对 WSACancelBlockingCall 的调用中断“。解决办法
- Java Charset的使用
- struct关键字在C和C++中使用时的一点区别
- 第15周报告1:冒泡排序算法
- 读完《Scala程序设计》,随便谈一些想法吧
- 第15周报告2: 学会操作字符数组
- Martin上海演讲实录1:Ruby是一个非常好的开发工具
- 选择排序算法