PDA

View Full Version : ComboBox selection to cause EditorGridPanel afteredit event



Chief Vas
26 Nov 2009, 11:38 AM
I have an Editor Grid Panel with a ComboBox in one column. I would like to update the database right after a selection is made in the Combobox. The afteredit event of the EditorGridPanel gives me all the data I need to update the record (I need an index number from a hidden column to know which record in the databse to update) but the afteredit does not fire until the combobox loses focus. The select event from the combobox fires when the selection is made but it only provides me (as far as I can see using firebug) info about the combo box it doesn't contain anything to tell me which record in the grid it is from.

Is there a way after selection in the combobox to force it to lose focus or cause it to fire the grids afteredit event or somehow tell what record in the grid it is from?

I've searched the forums all day but the closest I can find deals with using select vs change with a combobox.

Snippet of code:

This gets me the table_index and the new value that I need to update the database. Unfortunately it only fires after the combobox (grid cell?) loses focus. The old value is just gravy to look at while testing.


var foo = new Ext.grid.EditorGridPanel({
...other config stuff goes here...
listeners: {
afteredit: function(edit_object){
console.log('Record = '+ edit_object.record.data.table_index +' New = ' + edit_object.value + ' Old = ' + edit_object.originalValue);
}
}
});

CrazyEnigma
26 Nov 2009, 3:03 PM
var id = edit_object.record.get('your primary key attribute name');

Chief Vas
26 Nov 2009, 4:55 PM
var id = edit_object.record.get('your primary key attribute name');


I can already get the value of the field I need via:

edit_object.record.data.table_index

Is there some advantage to using the get() function or is it just another way to skin the cat?


var id = edit_object.record.get('table_index');