Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Daniel on Mar 24, 2008 21:16
open dhtmlx forum
What is combo.save(), combo.restore() and combo.remove()? Not in the documentation.

I was looking at the provided sample for using combo in grids and found the follow code:
<script>
function myf(stage,id,index){
var ind=mygrid.getRowIndex(id);
if ((index==5)&&(stage==0))//start edit Shipping column
{
var combo=mygrid.getCombo(5);
if (ind%2==1){ //for even rows
combo.save(); //save initial state
combo.remove(1);
combo.remove(2);
combo.remove(3);
}
else{
combo.save(); //save initial state
combo.remove(4);
combo.remove(5);
combo.remove(6);
}
}

if ((index==5)&&(stage==2)) //for finishing edit
mygrid.getCombo(5).restore(); //restore combo state
return true;
}
....

What is combo.save(), combo.restore() and combo.remove()? Nothing in the documentation about them or what they do?

Can you please explain?

Daniel,
Answer posted by Support on Mar 25, 2008 02:52

Managing selectbox collection ( co, coro excells )


To get collection common for whole column next method can be used
combo = grid.getCombo(index);
if collection need to be specific for cell
combo = grid.getCustomCombo(index)
The collection supports next API

    combo.put(value,label) - add new record in collection
    combo.remove(value) - remove record from collection
    combo.clear() - remove all records from collection

    combo.size() - return current size of combobox
    combo.get(value) - returns label by value
    combo.getKeys() - return an array of all possible values

    combo.save() - save current state
    combo.restore() - restore previously saved state


The less common use-case - get value by label can be done with next code
var value = combo.values[combo.keys._dhx_find(key)];





Answer posted by Daniel on Mar 25, 2008 16:00

Thank you.

Is this mentioned  anywhere in the documentation provided with each release?

Daniel,

Answer posted by Support on Mar 26, 2008 04:04
Current documentation has only brief mentioning of combo methods, the text above taken from draft of extended documentation, which will be released in nearest time.