PDA

View Full Version : different values for a ComboBox on each row of an EditorGrid



andreik65
19 Feb 2009, 11:49 PM
Hello,

I'm trying to manage different values for a ComboBox on each row of an EditorGrid.

Basically, a column of the grid is a ComboBox whose selectable values are not statically defined at grid build time, but change every time the user selects a different row.

Currently I'm using gwt-ext where they provided a method setUserCustomCellEditor on ColumnModel. You can pass it a subclass of UserCustomCellEditor. It's got one method, public GridEditor getCellEditor(int colIndex, int rowIndex). It's called any time a cell is about to enter editing. It gives me the ability to initialize the ComboBox with different values.

How can I do it with Ext GWT?

Thanks.
Andrea

odwyers
12 Jan 2011, 1:53 PM
We are looking for this functionality as well in GXT where we can override a ColumnModel method getCellEditor(col, row) and provide a row specific cell editor for an EditorGrid.
Has anyone achieved this ?

Thanks,

Sean

routologic
9 Jan 2012, 3:13 AM
Hi all,

we would also need the functionality in GXT to have different cell editors depending on the actual row data...
Has anyone found a solution so far?

Thanks,
Gergely

vidj
27 Feb 2012, 11:56 PM
Hi everyone,

we actually found a solution for ExtJS maybe it can be adapted for GWT:

Grid-Col has an editor:


{
xtype:'editorgrid',
id: 'somegrid',
store: this.store,
cm: new Ext.grid.ColumnModel([
{
id:'some_category',
header: 'Category',
dataIndex: 'category_id',
renderer: this.getCategoryText
},
{
id:'category_val',
header: 'Value',
dataIndex: 'value_id',
renderer: this.getValueText,
editor: new Ext.form.ComboBox({
id: 'value',
name: 'value',
mode: 'local',
store: this.valueStore, //this is an empty store
valueField:'value_id',
displayField:'value_text'
})
}
]),
listeners:{
beforeedit:this.getComboValues
}
}// -- eo grid

then there is a function getComboValues:



function getComboValues(e){

var combobox = Ext.getCmp('value');

//create tmp store for impact levels
var tmpStore = new Ext.data.Store({
reader: new Ext.data.JsonReader({
root:'data',
id: 'value_id',
fields:['value_id','value_text']
}, Ext.data.Record.create([
{name: 'value_id'},
{name: 'value_text'}
])),
//fill here your store with the specific data for the combobox
data: e.grid.valueStore.getById(e.record.get('category_id')).data
});

//bind the tmpStore to the combobox and set the value that was selected
combobox.bindStore(tmpStore);
combobox.setValue(e.value);

return true;
}


hope i could help

greetz

vidj

routologic
12 Mar 2012, 1:00 AM
Thanks vidj!

I will see if I can implement it in GXT. Anyway, if somebody have already got it, do not hesitate to post a reply.

Thanks once more,
Gergely