Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Nikita on Aug 14, 2008 08:18
open dhtmlx forum
Error on grid.parse(csvstring,"csv")

Hello, I am trying out your grid component for our company to see if this is what we need, but I am having troubles with parsing csv string into the grid object.

I am having this error:"Microsoft JScript runtime error: 'this.obj.firstChild' is null or not an object"

I am using ASP.NET to create the CSV string , and it looks like this :

101,Dent Carry,US,Sigmasoft L,33.9,56.9,453.9,120.7\n102,RA,Ed,Sidney,61,31,80,47\n103,CA,Pa,Solomon,82,70,33,38\n104,MA,Le,Glendon,90,77,98,36\n105,SP,Te,Edwin,100,33,84,41\n106,SP,Br,Mike,35,73,97,83\n107,MA,Je,Keith,50,57,80,46\n108,CA,Ev,Chris,66,76,43,63\n109,IN,Ro,Samuel,63,49,85,68\n110,MA,Gl,Oscar,94,96,62,33\n111,MA,Co,Peter,76,86,77,67\n112,MA,Ja,Benson,88,96,56,33\n113,UK,Fr,Lance,87,85,47,66\n114,MA,Bi,Donald,64,70,76,87\n115,CA,Se,Hunk,50,45,46,72\n116,IN,LV,Bob,62,64,61,61\n117,US,Ja,Coli,72,92,56,41\n118,IN,Br,Ivan,68,62,66,78\n119,SP,Sa,Vern,93,66,85,71

as far as I can tell, this is correct format. I am also having similar problem when trying to load xml string, which also looks correctly formed. I can open it through xml viewer.
This is my init js function, which is basically your example:

function doInitGrid(){

mygrid = new dhtmlXGridObject('mygrid_container');
mygrid.setImagePath("codebase/imgs/");
mygrid.setHeader("order_no,employee,country,customer,order2005,order2006,order2007,order2008");
mygrid.setInitWidths("*,*,*,*,*,*,*,*");
mygrid.setColAlign("left,right,right");
mygrid.setColSorting("int,str,str,str,float,float,float,float");
mygrid.setSkin("light");

// var xml = getTestData('xml');
//mygrid.loadXML(xml);
var csvstr = getTestData('csv');

mygrid.parse(csvstr,"csv");
mygrid.init();

}




========================================================================
the break is happening in dhtmlxgrid.js line 759 : if (_isKHTML)this.obj.appendChild(r);else {this.obj.firstChild.appendChild(r)}else {this.rowsCol[ind].parentNode.insertBefore(r, this.rowsCol[ind])};this.rowsCol._dhx_insertAt(ind, r);return r},

on

this.obj.firstChild.appendChild(r)
Answer posted by Support on Aug 14, 2008 09:06

The order of commands must be 

mygrid.init(); //init grid structure before loading data
mygrid.parse(csvstr,"csv");