PDA

View Full Version : comboBox in grid - on submit send id and not value



hadi78
20 Oct 2009, 5:20 AM
hi

i already searched the forum and couldn't find any answers to my problem. i have some comboboxes in my grid. the grid itself is inside a form. if i submit the form now, the value of the selected fields in the combox is send to the server, but i want the id of the selected combobox fields to be send. Can't figure out how to do that :(

here is my code:




var rec = Ext.data.Record.create([{
name: 'From country',
type: 'string'
}, {
name: 'To country',
type: 'string'
}, {
name: 'Means of Transportation',
type: 'string'
}, {
name: 'Use of Document',
type: 'string'
}, {
name: 'Border Crossing',
type: 'string'
}
]);


var store = new Ext.data.GroupingStore({
reader: new Ext.data.JsonReader({fields: rec}),
});

var editor = new Ext.ux.grid.RowEditor({
saveText: 'Add'
});

var grid = new Ext.grid.GridPanel({
store: store,
width: 900,
id: 'add-case-transportation-'+vCase.id,
region:'center',
fieldLabel: "Country",
height: 120,
margins: '0 5 5 5',
autoExpandColumn: 'from_country',
plugins: [editor],
view: new Ext.grid.GroupingView({
markDirty: false
}),
tbar: [{
icon: '/ext/examples/shared/icons/fam/add.gif',
text: 'Add',
handler: function(){
var e = new abuse({
from: 'Select..',
to: 'Select..',
means_of_transportation: 'Select..',
use_of_document: 'Select..',
border_crossing: 'Select..'
});
editor.stopEditing();
store.insert(0, e);
grid.getView().refresh();
grid.getSelectionModel().selectRow(0);
editor.startEditing(0);
}
},{
ref: '../removeBtn',
icon: '/ext/examples/shared/icons/fam/delete.gif',
text: 'Remove',
disabled: false,
handler: function(){
editor.stopEditing();
var s = grid.getSelectionModel().getSelections();
for(var i = 0, r; r = s[i]; i++){
store.remove(r);
}
}
}],

columns: [
new Ext.grid.RowNumberer(),
{
id: 'from_country',
header: 'From',
width: 150,
dataIndex: 'from',
sortable: true,
editor: {
displayField: 'country_label',
xtype: 'combo',
allowBlank:true,
mode: 'local',
name: 'from',
hiddenName: 'from',
store: countries,
valueField: 'country_label',
triggerAction: 'all'
}
},{
header: 'To',
dataIndex: 'to',
width: 150,
sortable: true,
editor: {
displayField: 'country_label',
xtype: 'combo',
//ddReorder: true,
allowBlank:true,
store: countries,
valueField: 'country_label' ,
triggerAction: 'all'
}
},{
header: 'Means of Transportation',
dataIndex: 'means_of_transportation',
width: 150,
sortable: true,
editor: {
displayField: 'label',
xtype: 'combo',
//ddReorder: true,
allowBlank:true,
store: meansOfTransportation,
valueField: 'label' ,
triggerAction: 'all'
}
},{
header: 'Document',
dataIndex: 'use_of_document',
width: 150,
sortable: true,
editor: {
displayField: 'label',
xtype: 'combo',
//ddReorder: true,
allowBlank:true,
store: useOfDocuments,
valueField: 'label' ,
triggerAction: 'all'
}
},{
header: 'Border Crossing',
dataIndex: 'border_crossing',
width: 150,
sortable: true,
editor: {
displayField: 'label',
xtype: 'combo',
//ddReorder: true,
allowBlank:true,
store: borderCrossing,
valueField: 'label' ,
triggerAction: 'all'
}
}
]
});

Condor
20 Oct 2009, 5:52 AM
Use:

{
xtype: 'combocolumn',
header: 'Border Crossing',
dataIndex: 'border_crossing',
width: 150,
sortable: true,
editor: {
xtype: 'combo',
store: borderCrossing,
displayField: 'label',
valueField: 'id',
triggerAction: 'all',
allowBlank: true
}
}
with the code from this feature request (http://www.extjs.com/forum/showthread.php?t=67488).

hadi78
20 Oct 2009, 6:08 AM
thx , i tried it out but get the following error:

combo.findRecord is not a function
record = combo.findRecord(co...lueField || combo.displayField, value);\n

did i miss something?

Condor
20 Oct 2009, 6:12 AM
And the editor is a ComboBox?

hadi78
20 Oct 2009, 6:16 AM
lool, sorry my mistake, somehow i had commented it out....guess working all day long isn't good for the concentration :) it seems to work now, many thx ;)