View Full Version : How to fill a combobox with grid columns information?

13 Jul 2010, 12:34 AM

I'm trying to fill a combobox with a grid columns information with as code below,

var grid = Ext.getCmp('gridPanel');
new Ext.form.ComboBox({
id: 'cmbSearchCriterias',
store: new Ext.ux.data.PagingStore({
id: "strComboStore",
ajaxEventConfig: {
formProxyArg: "form1"
reader: new Ext.data.JsonReader({
fields: [{ name: "Text" }, { name: "Value"}],
id: "Value"
autoLoad: true,
proxy: new Ext.data.PagingMemoryProxy({})
displayField: 'Text',
valueField: 'Value',
triggerAction: 'all',
mode: 'local',
onFocus: function() {
var combobox = this;
//var data = new Array();
Ext.each(grid.colModel.columns, function(col, i) {
combobox.insertRecord(i, { Text: col.header, Value: col.dataIndex });
// alert(col.header);
}); // eof each

If I execute the alert function inside the each iteration, it works well and showing me the column header. But the insertRecord method is not working. I wanted to list the column headers of a grid into a combobox when the combobox is focused.


15 Jul 2010, 5:10 AM
why not just add the record instead of insert?