Get the data of combobox
comboDS = new Ext.data.JsonStore ({
url : 'test.do',
fields : [{
name : 'id'
}, {
name : 'display'
}]
});
combobox definition
The id in the combobox must be present, and the combobox value must be obtained based on the id.
var comboBox = new Ext.form.ComboBox({
id : "cb", //Must have
typeAhead : true,
readOnly : true,
allowBlank : false,
autoScroll : true,
selectOnFocus : true,
emptyText : 'Please select...',
store : comboDS,
forceSelection : true,
triggerAction : 'all',
displayField : 'display',
valueField : 'id'
});
Grid definition:
ds = new Ext.data.Store({
baseparams : {
start : 0,
limit : RowCount
},
proxy : new Ext.data .HttpProxy({
url :'test2.do'
}),
reader : new Ext.data.JsonReader({
root : 'data',
totalProperty : 'totalCount'
}, [{
name : "bh"
}, {
name : "test"
}]);
});
var cm = new Ext .grid.ColumnModel([new Ext.grid.RowNumberer(), {
header : "Number",
dataIndex : "bh"
}, {
header : "Test",
dataIndex : "test",
renderer : renderer,
editor : comboBox
}]);
grid = new Ext.grid.EditorGridPanel({
title : 'Test',
ds : ds,
cm : cm,
clicksToEdit : 1,
viewConfig : {
forceFit : true
},
bbar : new Ext.PagingToolbar({
pageSize : RowCount,
store : ds,
displayInfo : true,
displayMsg : 'Display records {0} to {1}, {2} in total',
emptyMsg : "No record"
})
});
cm renderer function
This method is to solve the problem of combobox being modified and displayed as id
function renderer(value, p, r) {
var index = comboDS.find(Ext .getCmp('cb').valueField, value);
var record = comboDS.getAt(index);
var displayText = "";
if (record == null) {
displayText = value;
} else {
displayText = record.data.display; // Get the value of the display field in the data set in record
}