扩展:Ext.ux.FplbField
Ext.ux.FplbField = Ext.extend(Ext.form.TriggerField, { initComponent : function() {
Ext.ux.FplbField.superclass.initComponent.call(this);
if (!this.treePanel) {
this.treePanel = new Ext.tree.TreePanel({
root : {
nodeType : 'async',
id : '_root',
text : '发票类别',
expanded : true
},
dataUrl : '/wsbx.do?p=getFplbTree'
});
}
if (!this.panel) {
this.panel = new Ext.Panel({
height : 200,
border : false,
autoScroll : true,
items : [this.treePanel]
})
}
},
menuEvents : function(method) {
this.treePanel[method]('click', this.onSelect, this);//给树添加单击事件
this.menu[method]('hide', this.onMenuHide, this);
this.menu[method]('show', this.onFocus, this);
},
onSelect : function(node, e) {//单击树节点赋值
this.setValue(node.id);
this.menu.hide();
},
onMenuHide : function() {
this.focus(false, 60);
this.menuEvents('un');
},
onTriggerClick : function() {
if (!this.menu) {
this.menu = new Ext.menu.Menu({
hideOnClick : false,
focusOnSelect : false,
items : [this.panel]
});
}
this.onFocus();
this.menu.show(this.el, 'tl-bl?');
this.menuEvents('on');
}
});
Ext.reg('fplbfield', Ext.ux.FplbField);在editorgrid里配置的column:
{
xtype : 'gridcolumn',
dataIndex : 'fplb',
header : '发票类别',
width : 100,
editor : {
xtype : 'fplbfield'
}
}
页面效果:实现效果:
onTriggerClick后显示tree,点击tree的节点,返回赋值