Error when Serialize to CSV

I got this error when I call the function SerializeToCSV and I don’t know why

dhtmlx.js?2.2.3:9 Uncaught TypeError: Cannot read property '0' of undefined dhtmlXGridObject._serializeRowToCVS @ dhtmlx.js?2.2.3:9 dhtmlXGridObject.serializeToCSV @ dhtmlx.js?2.2.3:9

I use this code for generate the rows

for(z in dati)
{
	if (z != "tot")
	{
	var id = parseInt(z)+parseInt(numControllo * dati.length);
	datiTable = []
	datiTable = ['']
	datiTable.push('F' + z);
							
	}
	else{
	var id =parseInt(numControllo * dati.length);
						
						
	datiTable = []
	datiTable.push(some value);
	datiTable.push('TOT');
	}
					
	if (numControllo % 2 == 0)
		var color = "#eee";
	else
		var color = "#fff";		
					
					
	datiTable.push(other value);
        datiTable.push(other value);
				
	dhxGrid.addRow(id,datiTable,id);
	dhxGrid.setRowColor(id,color);
}

dhxGrid.setRowspan(numControllo * dati.length,0,4);
dhxGrid.setColTypes("ro,ro,ro,ro");

I solved my problem, thanks for help, but now I have another one:

My first column has a rowspan and when I’m sorting the table, it will ruin

Here an example:

starting table :

|column 1         |  column 2    |    column 3    |

| date            | value1       | value2         |
| #rowspan        | value1       | value2         |
| date2           | value1       | value2         |
| #rowspan        | value1       | value2         |

table after sorting :

|column 1      |  column 2  |    column 3 |

| date         | value1     | value2      |
| date2        | value1     | value2      |
| value1       | value2     |
| value1       | value2     |

Unfortunately the described problem cannot be reconstructed locally.
The following sample sorts well:
dhtmlx.com/docs/products/dhtmlxG … wspan.html
If the problem still occurs for you please, provide with a complete demo, where it can be reproduced.
Here you can find tutorial about creating a complete demo:
docs.dhtmlx.com/tutorials__auxil … pport.html