Ext的TriggerField的问题


Ext.form.ShiftDefRefField = Ext.extend(Ext.form.TriggerField, {

triggerClass: 'x-form-ref-trigger',
initComponent: function() {
Ext.form.ComboBox.superclass.initComponent.call(this);
this.ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: 'GetSomeShiftDefRef', method: 'GET' }),
reader: new Ext.data.JsonReader({ totalProperty: 'totalProperty', root: 'root', id: 'id' },
[{ name: 'ID' }, { name: 'Code' }, { name: 'Name' }, { name: 'Description' }, { name: 'ShiftType'}])
});
this.ButtonOK = new Ext.Button({ id: 'RefButtonOK', text: 'OK', tooltip: 'OK', iconCls: 'add' });
this.sm = new Ext.grid.CheckboxSelectionModel();
this.cm = new Ext.grid.ColumnModel([
this.sm,
{ header: 'Code', width: 100, dataIndex: 'Code', sortable: true },
{ header: 'Name', width: 100, dataIndex: 'Name', sortable: true },
{ header: 'Description', width: 100, dataIndex: 'Description', sortable: true },
{ header: 'ShiftType', width: 100, dataIndex: 'ShiftType', sortable: true}]);
this.gridMain = new Ext.grid.GridPanel({
store: this.ds,
cm: this.cm,
sm: this.sm,
stripeRows: true,
height: 300,
width: 500,
loadMask: true,
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: this.ds,
displayInfo: true,
displayMsg: 'From {0} to {1} , total: {2}',
emptyMsg: "No record"
}),

tbar: new Ext.Toolbar({
items: [this.ButtonOK]
})
});
this.windowRef = new Ext.Window({
layout: 'fit',
modal: true,
height: 300,
width: 500,
title: 'Select',
closeAction: 'hide',
plain: true,
items: this.gridMain
});
this.ButtonOK.on('click', this.ButtonOK_Click, this, { preventDefault: true });
},

ButtonOK_Click: function() {
var selectedItems = this.gridMain.selModel.selections.keys;
if (selectedItems.length == 0) {
Ext.MessageBox.alert('Error', 'Please select on record!');
}
else {
var selectedRow = this.gridMain.getSelectionModel().getSelected();
this.windowRef.hide();
// this.setValue(selectedRow.get('Code'));
var text = selectedRow.get('Code');
Ext.form.ShiftDefRefField.superclass.setValue.call(this, text);
}
},
onTriggerClick: function() {
this.ds.load({ params: { start: 0, limit: 20} });
this.windowRef.show();
}
});


这是那个控件的代码

{ header: "ShiftDef", width: 100, dataIndex: 'ShiftDef', sortable: true, editor: ShiftDefRef }

使用控件的EditorGrid的一列


-------------------------------------------------------------
------------------------------------------------------------------
再说明一点:

这个扩展的控件, 就是在 initComponent 中 建立了一Grid

this.ButtonOK.on('click', this.ButtonOK_Click, this, { preventDefault: true });

给Grid上的Button添加了事件处理

然后再ButtonOK_Click中关闭Window, 返回ID,
但是这段方法:
var selectedRow = this.gridMain.getSelectionModel().getSelected();
this.windowRef.hide();
// this.setValue(selectedRow.get('Code'));
var text = selectedRow.get('Code');
Ext.form.ShiftDefRefField.superclass.setValue.call(this, text);

window也关闭了, Code的值也获取到了
就是this.setValue()方法没有起作用(在IE7中偶尔会起作用)

-------------
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值