Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Turik Campbell on Jan 05, 2010 05:36
open dhtmlx forum
When exporting the Grid to CSV, How can I exclude Row Number column, etc?


Support,

When exporting the grid to CSV, I noticed that the row number column is automatically included in my csv output.
It appears that the row number is included within the grid's definition even though I have not explictly defined
it as a column

Please answer the following:

1. How can I exclude the row number column? You will notice that the column descriptions appear to be 'off' by 'one'.
'Column1' should begin in the second column (ie: where date values begin), 'Column2' in the third column, and so forth.

Here is my current csv output:

Column1 Column2 Column3 Column4 Column5    
0    12/1/2009    250,251    241,173    250,251    241,173
1    12/2/2009    285,112    278,520    285,112    278,520
2    12/3/2009    269,288    269,062    269,288    269,062
3    12/4/2009    284,414    284,355    284,414    284,355

What can I do to make it look like this:

Column1 Column2 Column3 Column4 Column5    
12/1/2009    250,251    241,173    250,251    241,173
12/2/2009    285,112    278,520    285,112    278,520
12/3/2009    269,288    269,062    269,288    269,062
12/4/2009    284,414    284,355    284,414    284,355

OR

2. In general, If I wished to include row number column, How can I give the row number column and explicit name like ie: "Row Number" so output would like this:

Row # Column1 Column2 Column3 Column4 Column5    
0    12/1/2009    250,251    241,173    250,251    241,173
1    12/2/2009    285,112    278,520    285,112    278,520
2    12/3/2009    269,288    269,062    269,288    269,062
3    12/4/2009    284,414    284,355    284,414    284,355

Here is my current code:

grid.enableCSVHeader(true);
grid.setCSVDelimiter("\t");
var csv=grid.serializeToCSV();


Best,
Turik
Answer posted by Stanislav (support) on Jan 06, 2010 01:52
       grid.enableCSVAutoID(false);
Answer posted by Turik on Jan 07, 2010 05:51

Support,

Excluding the row number column using the following code:

'grid.enableCSVAutoID(false);'

does not work.  After further research, it appears that the aforementioned api is used for loading data only. 

In general, when defining the grid, should the developer include row id field as part of the definition.. as I really do not have

the luxury of going back to include it.. I would appreciate some other alternatives... ?

Example .xml snippet:

:

<column id="row number" width="0" type="ro" align="left" sort="int">row number</column>

<column id="column 1" width="50" type="ro" align="left" sort="int">column 1</column>

<column id="column 2" width="50" type="ro" align="left" sort="int">column 2</column>

Answer posted by Alex (support) on Jan 11, 2010 06:31

Sorry for the misleading information. Try to call enableCSVAutoID method with true instead of false to not to include row id into the serialized string:

grid.enableCSVAutoID(true);