PDA

View Full Version : [SOLVED] Different ComboBoxes in one grid column



PranKe01
7 Feb 2010, 9:13 AM
Hi guys,

I got a EditorGridPanel and want to show ComboBoxes in one column. That works good for now, but I need to show different ComboBoxes depending on a value of a field in the row.
My ColumnModel looks like this:

var colModel = new Ext.grid.ColumnModel([
selModel,
{header: "Group", width: 100, sortable: true, dataIndex: 'group'},
{header: "Name", width: 100, sortable: true, dataIndex: 'name'},
{header: "Lastname", width: 100, sortable: true, dataIndex: 'lastname'},
{header: "Role", width: 90, sortable: true, dataIndex: 'role'},
{header: "Access", width: 130, sortable: true, dataIndex: 'accessrole', editor: firstCombo, renderer: getText}
]);

But how can I set another editor instead of firstCombo for some rows only?

Thanks for any help!

PranKe01
10 Feb 2010, 3:57 AM
Hi guys,

isn't it possible or does no one got an idea?

PranKe01
10 Feb 2010, 5:18 AM
I found a solution now :)

I added a listener to the EditorGrid, in which I filter the store:

var firstCombo = new Ext.form.ComboBox({
store: YOURCOMBOSTORE,
...
triggerAction: 'all',
lastQuery: '',
lazyRender: true,
listClass: 'x-combo-list-small'
});

var grid = new Ext.grid.EditorGridPanel({
store: ds,
sm: selModel,
cm: colModel,
clicksToEdit: 1,
listeners: {
cellmousedown: function(grid, rowIndex, columnIndex, event){
var record = grid.getStore().getAt(rowIndex);
YOURCOMBOSTORE.filterBy(function(rec, id){
if (record.data['YOURSTOREITEM'] == "value1" && rec.data['YOURCOMBOSTOREITEM'] == "value2") {
return false;
}
return true;
});
}
}
});

Hope I could help someone ;)