Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Peter Ang on Sep 10, 2007 03:05
open dhtmlx forum
Changing LoadMode of dhtmlXcombo in Grid.

i would like to be able to programmatically changing the loading mode of dhmtlxcombo in a grid. For example, I have two dhtmlxcombo in a row in a datagrid, combo1, combo2. Based on selection from combo1, i'd like to be able to programmatically change dataloading of combo2. For example, if combo2 is initially loaded with options from an xml file, I want to programmatically change it to autofilter with a url pointing to a data source and also vice versa.
Answer posted on Sep 11, 2007 10:43
 You can use setOnEditCellHandler to set function called when cell is edited (for more details see in documentation doc/alpha.html#api_a).

 Combo object is created when editor is open (stage=1 in onEditCell handler). So when you open combo2, combo1 does not exists. And to get value which was selected in combo1, you have to address to the grid cell object:

comboValue = grid.cells(rowId,columnIndex).getValue()
 
Please, try to use following approach  to programmatically changing the loading mode of dhmtlxcombo in a grid (for example, combo1 has row_id="0" column_index=1, combo2 - column_index=2):

function myf(stage,id,index){
      combo1_value = grid.cells("0",1).getValue();
      if ((index==2)&&(stage==1)){ //start edit combo2 column
            if(combo1_value == "loadXML"){
 var combo=this.editor.obj;
 combo.clearAll();
 combo.loadXML("data.xml")
            }
      }
        return true;
}
mygrid = new dhtmlXGridObject('gridbox');
mygrid.imgURL = "../../codebase/imgs/";
mygrid.setOnEditCellHandler(myf);
mygrid.loadXML("combo.xml");

By default, you can set list of options in the "combo.xml":
<column type="combo"...>Combo1
 <option value="1">loadXML</option>
 <option value="2">from list</option>
</column>  
<column type="combo"...>Combo2
 <option value="1">one</option>
...
 <option value="10">ten</option>
</column>