Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Berkich on Jun 26, 2008 19:10
open dhtmlx forum
Dynamic load a combo once and use the values in numerous combo boxes through out the grid

I have a grid with up to 25 columns, each of which has a combo box in the cell. When the grid gets displayed I would like to make a dynamic request back to the server to get the combo box options and then populate all of the combo boxes in each row and cell.

Thanks
Dan
Answer posted by Support on Jun 27, 2008 02:38
grid.loadXML(url,function(){
    //after load
    var combo=grid.getColumnCombo(0);   //get first combo
    combo.loadXML(some_url,function(){   //load data in it
        for (var i=1; i<grid.getColumnsNum(); i++){   //when loaded, for all other combos
           var combo=grid.getColumnCombo(i);
           combo.loadXMLString(this.xmlDoc.responseText);   // load the same data
        }
    })
});
Answer posted by berkich on Jun 27, 2008 06:47
Thanks very much! Looks like it should work.  I am using grid version 1.3 so it appears that I will have to upgrade in order to take advantage of this solution.....
Answer posted by Support on Jun 28, 2008 03:54
Described scenario will work for "combo" type of column, which is not available in your version of grid.
You can use more rough approach

grid.loadXML(url,function(){
    (new dtmlXMLLoaderObject(function(a,b,c,d,xml){
        var options=xml.doXPath("//option");
        for (var i=0; i<grid.getColumnsNum(); i++){   //when loaded, for all other combos
           var combo=grid.getCombo(i);
           for (var j=0;  j<options.length; j++)
                combo.put(options[j].getAttribute("value"),options[j].firstChild.data);
        }
    },this,true,true)).loadXML("combo.xml");
})