Ext.ux.FplbField 返回单元格赋值失败
[code="js"]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);[/code]
在editorgrid里配置的column:
[code="js"]{
xtype : 'gridcolumn',
dataIndex : 'fplb',
header : '发票类别',
width : 100,
editor : {
xtype : 'fplbfield'
}
}[/code]
页面效果:
[img]http://218.75.78.166/test/fplb.jpg[/img]
实现效果:
onTriggerClick后显示tree,点击tree的节点,返回赋值
已经测试ok
下面是修改后的代码以及所加代码:
[code="java"]
var getSelectRows = function(g) {
var records = [];
var selModel = g.getSelectionModel();
if (selModel.getSelections) {
records = selModel.getSelections();
} else {
var pos = selModel.getSelectedCell();
if (pos == null) return records;
var record = g.getStore().getAt(pos[0]);
if (record) records = [record];
}
return records;
}
[/code]
插件代码:
[code="java"]
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 : new Ext.tree.TreeNode({
// nodeType : 'async',
id : '_root',
text : 'xzd',
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) {//单击树节点赋值
var gdom = this.el.findParentNode('div.x-grid-panel');
var grid = Ext.getCmp(gdom.id);
var tagRecord;
if (grid) {
var selRecord = getSelectRows(grid);
if (selRecord && selRecord.length > 0) {
tagRecord = selRecord[0];
}
}
tagRecord.set(this.nameValue,node.text);
tagRecord.commit();
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);
[/code]
使用例子:
[code="java"]{
header: 'Indoor?',
dataIndex: 'indoor',
width: 55,
editor : {
xtype : 'fplbfield',
nameValue:"indoor"
}
}[/code]
上面插件代码中的root部分 你换成你原来自己的代码
关键是插件代码中的onSelect 部分处理
貌似没有加renderer渲染函数处理