首页 新闻 会员 周边

扩展Ext的TriggerField的问题

0
悬赏园豆:50 [已关闭问题]

需要做一个Ext的参照控

就是类似Combo那样, 但是点击后会弹出一个window

在window的grid里选择需要的数据, 会把ID返回到控件里

不太会javascript, 就摸索着扩展TriggerField做了一个, 如下图:

现在情况是: 把这个控件用在form里, 正常

但用在EditorGrid里, 就有问题:

在Firefox下, 获取了ID后, 返回不到Cell里 (可以看到Cell已被修改)

在IE7下, 有时可以返回, 有时不能返回 (还没看出规律)

我的代码如下:

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();
}
});

在initComponent 中 建立了一Grid, 并充值

最关键的问题就是

点击OkButton后, 执行ButtonOK_Click方法

在this.setValue(selectedRow.get('Code'));中

Code已经能获得了, 但是setValue却不起作用

 

请高手指教, 万分感谢!!

flankerfc的主页 flankerfc | 初学一级 | 园豆:0
提问于:2008-12-07 22:56
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册