ext combobox editgrid

My solution to this problem is as follows:
I would like to get both the display text and the value text.
1)Define the comboBox
Code:
var displayTextCB = new Ext.form.ComboBox({
typeAhead: true,
mode: 'local',
triggerAction: 'all',
transform:'displayTextSel',
selectOnFocus:true,
lazyRender:true,
listClass: 'x-combo-list-small'
});)
Define two column field used for comboBox when new ColumnModel, one used for display only and the other contain the exact value.
Code
{
header: "Display Text",
dataIndex: 'displayText',
width: 130,
renderer: displayTextLabelValue,
editor: displayTextCB
},
{
header:"Display Value",
dataIndex: 'displayValue',
hidden: true
},
3)Define render function on the display field,say displayTextLabelValue
which has two function:
a) return the text to the display Name with combobox
b) set value to the hidden diaplay value
Code:
function displayTextLabelValue(val, params, record){
//store value in hidden column
var opts = displayNameCB.store.data.items;
for(var i = 0, len = opts.length;i < len; i++){
if (opts[i].data.value == val){
record.data.displayValue=val;
return opts[i].data.text;
}
}
return val;
};

or

Then in the 'afteredit' event of the grid I add/update the value to the record

Code:
grid.on('afteredit', function(o){
if(o){
var grid=o.grid;
var record=o.record;
var cm=grid.getColumnModel();
var editor=cm.getCellEditor( o.column, o.row);
var v=editor.getValue();

if(editor.field.hiddenField){
var v=editor.field.hiddenField.value;
record.set('selected', v);
}
}
});Finally, when you get modified records the value is there
Code:
Ext.getCmp('saveButton').on('click', function(...){
var grid=Ext.getCmp('dispatchlogic_grid');
var modified=grid.getStore().getModifiedRecords();
for(var i=0;i<modified.length;++i){
}
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值