Combo box in Grid

I’m using a combo box inside a grid. The functionality which I needed was like ‘when the user selects value from combo box it should update the database with the selected value. If user enters the data manually for the combo box field that value is supposed to be added to the combo box listing and updated in the database.’



mygrid.attachEvent(“onEditCell”,onEditCell);



//called each time when cell changed

function onEditCell(stage,id,index,value){

    if(stage==2){

        alert(id+""+index+""+value);

    }

    return true;

}



With this event I can grab the value which is selected by the user from the combo box listing and update the database but I could not get the value which is manually entered by the user for combo box. I read from other Q and A’s that “The event will occur when text changed and focus moved outside of control” but that couldn’t help me to grab the manually entered value. Any suggestions?

In order to know if an option with a certain value is presented in options list, you can use getOption(value) method of the combo. This method returns the option if it exists and null in the other case.

So, the approach can be the following:

mygrid.attachEvent(“onEditCell”,function(stage,id,index,value){
    if(stage==2){
        var combo = mygrid.getColumnCombo(index);
        var z=combo.getOption(value);
        if(!z) combo.addOption(value,value);
        …
     }
     return true
})

Thanks for the quick reply. The problem is that I can not get the value which I typed in the combo to the function atall. When I do an alert for the ‘value’ it shows me either the previous value or null(if it does not have a prev value) but not the value which I typed in. Any suggestions?