dhxGrid

Good evening, I have the following problem if comment alert ( “grid”) comes out an error “this.obj.firstChild is null” but if I enable alert (grid) works

thanks,



setGrid();

setGriglia(ricattesa);







function setGrid() {

    dhxGrid = dhxLayout.cells(“a”).attachGrid();    

    dhxGrid.setImagePath(patdhtmlxGrid);        

    dhxGrid.attachEvent(“onRowSelect”, getRigaGrid);

    dhxGrid.attachEvent(“onEditCell”, doOnCellEdit);

    dhxGrid.attachEvent(“onEnter”, doOnEnter);

    dhxGrid.attachEvent(“onRightClick”, function(id, ind, obj) {

         alert(“Row with id-ind-obj=”+id+ind+obj);

            

    dhxGrid.attachHeader("

,"

                     + “#rspan,#rspan,#rspan”);

    dhxGrid.loadXML(patxmlgrid,

            function() {

            // set titolo filtro field

                var authFlt = document.getElementById(“title_flt”)

                             .appendChild(document.getElementById(“title_flt_box”).childNodes[0]);

                dhxGrid.hdr.rows[2].onmousedown = dhxGrid.hdr.rows[2].onclick = function(e) {

                                                    (e || event).cancelBubble = true;}

                dhxGrid.setSizes();

            });    

}





function setGriglia(ricattesa){

    inResp = new Array();

    

    inResp[0]=“Luned�”;

    inResp[1]=“Marted�”;

    inResp[2]=“Mercoled�”;

    inResp[3]=“Gioved�”;

    inResp[4]=“Venerd�”;

    inResp[5]=“Sabato”;

    inResp[6]=“Domenica”;





    alert(“Griglia”); <<<<<<--------------------------------------- ok no error



//alert(“Griglia”); <<<<<<--------------------------------------- no ok error





    

    for (var i = 0; i < inResp.length; i++) {

     canc = “#”;

     dhxGrid.addRow(i + canc + inResp[i], inResp[i] + “,” + // metodi dentro file java Filevo

inResp[i] + “,” + inResp[i] + “,” + inResp[i]

+ “,” + “path”

);

    

     dhxGrid.setUserData(i + inResp[i], “name”, inResp[i]);

}

}



============================================

errore

============================================



this.obj.firstChild is null

anonymous(tr., Object name=ind value=0, Object name=skip)dhtmlxgrid.js (riga 729)

anonymous(“0#Luned�”, [“Luned�”, “Luned�”, “Luned�”, 2 more… 0=Luned� 1=Luned� 2=Luned� 3=Luned� 4=path], Object name=ind value=0)

In your code, configuration is loaded from XML, and row adding will not be processed correctly if it will be executed before configuration loading.
The data loading is async. , so you need to wait for it before adding rows.


setGrid();
// setGriglia(ricattesa); - too early


dhxGrid.loadXML(patxmlgrid,function() {
// set titolo filtro field
var authFlt = document.getElementById(“title_flt”)
.appendChild(document.getElementById(“title_flt_box”).childNodes[0]);
dhxGrid.hdr.rows[2].onmousedown = dhxGrid.hdr.rows[2].onclick = function(e) {
(e || event).cancelBubble = true;}
dhxGrid.setSizes();

setGriglia(ricattesa); //can be safely executed
});