PDA

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



xantiax
12 Jul 2010, 10:25 PM
Hi,

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




var grid = Ext.getCmp('grdTest');
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;
combobox.store.removeAll();
Ext.each(grid.colModel.columns, function(col, i) {
combobox.insertRecord(i, { Text: col.header, Value: col.dataIndex });
// alert(col.header);
}); // eof each
});


Could anyone guide me to do that? If I execute an alert as "alert(col.header);" inside the each iteration, it works well, but it doesn't add the information as a combobox item with "insertRecord" method.

Thanx..

13 Jul 2010, 4:22 AM
Hi,

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




var grid = Ext.getCmp('grdTest');
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;
combobox.store.removeAll();
Ext.each(grid.colModel.columns, function(col, i) {
combobox.insertRecord(i, { Text: col.header, Value: col.dataIndex });
// alert(col.header);
}); // eof each
});


Could anyone guide me to do that? If I execute an alert as "alert(col.header);" inside the each iteration, it works well, but it doesn't add the information as a combobox item with "insertRecord" method.

Thanx..

The comboBox does not have a insertRecord method.