ComboBoxTree
3885 단어 ext
Ext.namespace("Ext.ux.form");
/**
* create by wjc
*/
Ext.ux.form.ComboBoxTree = Ext.extend(Ext.form.ComboBox, {
treeId : Ext.id()+'-tree',
maxHeight :300,
selectedClass : '',
mode : 'local',
triggerAction: 'all',
onSelect : Ext.emptyFn,
editable : false,
//all:
//exceptRoot: ,
//folder: ( )
//leaf:
selectNodeModel : 'exceptRoot',
//private
initComponent: function(){
this.initComboBoxTree();
Ext.ux.form.ComboBoxTree.superclass.initComponent.call(this);
},
initComboBoxTree:function(){
this.tpl = new Ext.Template('<tpl for="."><div style="height:'+this.maxHeight+'px"><div id="'+this.treeId+'"></div></div></tpl>');
this.store = new Ext.data.SimpleStore({fields:[],data:[[]]});
if(!this.tree){
var initComboBoxTree_Page =this;
this.tree = new Ext.tree.TreePanel({
loader: new Ext.tree.DWRTreeLoader({
dataUrl:this.DWRfunc,
isteners : {
'beforeload' : function(node) {
initComboBoxTree_Page.getLoader().args[0]=(node.id!='0'?node.id:"1");
}
}
}),
root : new Ext.tree.AsyncTreeNode({
text: this.rootlable,
draggable:false,
id:'1'
})
});
}
},
expand : function(){
Ext.ux.form.ComboBoxTree.superclass.expand.call(this);
if(!this.tree.rendered){
this.tree.height = this.maxHeight;
this.tree.border=false;
this.tree.autoScroll=true;
if(this.tree.xtype){
this.tree = Ext.ComponentMgr.create(this.tree, this.tree.xtype);
}
this.tree.render(this.treeId);
var combox = this;
this.tree.on('click',function(node){
var isRoot = (node == combox.tree.getRootNode());
var selModel = combox.selectNodeModel;
var isLeaf = node.isLeaf();
if(isRoot && selModel != 'all'){
return;
}else if(selModel=='folder' && isLeaf){
return;
}else if(selModel=='leaf' && !isLeaf){
return;
}
combox.setValue(node);
combox.collapse();
});
var root = this.tree.getRootNode();
if(!root.isLoaded())
root.reload();
}
},
setValue : function(node){
var text = node;
if(node.text)
text = node.text;
if(this.valueField){
var r = this.findRecord(this.valueField, node.text);
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.text;
}
Ext.ux.form.ComboBoxTree.superclass.setValue.call(this, text);
this.value = node.text;
return this;
},
getValue : function(){
return typeof this.value != 'undefined' ? this.value : Ext.ux.form.ComboBoxTree.superclass.getValue.call(this);
}
});
Ext.reg('combotree', Ext.ux.form.ComboBoxTree);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
ExtJS 3.2 학습 노트(3) 사용자 정의 이벤트Extjs에서 모든 상속은 Ext.util에서 합니다.Observable 클래스의 컨트롤은 이벤트를 지원할 수 있습니다. 클래스에 대해 이벤트를 사용자 정의하려면 다음 절차를 따르십시오. 1, 먼저 클래스를 정의합니...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.