Categories | Question details Back To List | ||
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("<div id='title_flt' style='padding-right:3px'></div>," + "#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) Answer posted by Stanislav (support) on Jan 14, 2010 02:38 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 }); |