forEachRow returns different id order than rendered

hi, i use standard edition 5.0 for my application; normally I use an ‘order by’ clause in my select that returns and renders rows in unordered id (as anag_id is id and “order by name, surname” is the clause)
when I use forEachRow to extract data from cells to a json row, it returns data in id order, and not in rendered order. for example:
return of connector with order by:

"
<row id='1917'><cell><![CDATA[AG]]></cell><cell><![CDATA[BASTANTE]]></cell><cell><![CDATA[Giulia]]>..../row>
<row id='2710'><cell><![CDATA[AG]]></cell><cell><![CDATA[BORDERI]]></cell><cell><![CDATA[Benedetta]]></cell>...</row>
<row id='2885'><cell><![CDATA[AG]]></cell><cell><![CDATA[CACCAMO]]></cell><cell><![CDATA[Gloriamaria]]></cell>...</row>
<row id='2244'><cell><![CDATA[AG]]></cell><cell><![CDATA[FONTANA]]></cell><cell><![CDATA[Gloria]]>...</row>
<row id='2779'><cell><![CDATA[AG]]></cell><cell><![CDATA[GANCI]]></cell><cell><![CDATA[Greta]]>...</row>
<row id='2409'><cell><![CDATA[AG]]></cell><cell><![CDATA[INNOCENTI]]></cell><cell><![CDATA[Sarah]]>...</row>
<row id='2707'><cell><![CDATA[AG]]></cell><cell><![CDATA[MARTOGLI]]></cell><cell><![CDATA[Sofia]]>...</row>
<row id='2586'><cell><![CDATA[AG]]></cell><cell><![CDATA[VENDETTI]]></cell><cell><![CDATA[Carla Maria]]></cell>...</row>
<row id='818'><cell><![CDATA[BB1]]></cell><cell><![CDATA[QUATTROPANI]]></cell><cell><![CDATA[Sebastiano]]></cell>...</row>
<row id='3668'><cell><![CDATA[BB2]]></cell><cell><![CDATA[INTURRISI]]></cell><cell><![CDATA[Nicole]]></cell><cell>...</row>..."

result of forEachRow:
Id: 818 (data of id 818)
Id: 1917 ()
Id: 2244 ()
Id: 2586 ()
and so on in id order
How can I obtain the same order as in rendered page?

By the way, the function getRowData doesn’t exist in my release of dhtmlxSuite

Can you help me?
thanks

Mmmm… it seems that I can develop on the example provided by Vitaly here: how can i export datagrid to a json string?
if I use Index instead of Id, it mantains the renderized order:

var visRow = {};
var i = 0;
Grid_a.forEachRow(function(id){
	i = Grid_a.getRowIndex(id);
	visRow[i] = [];
	Grid_a.forEachCell(id, function(ncell,ind) {
		visRow[i][ind] = ncell.getValue();
	});
	visRow[i][Grid_a.getColumnsNum()] = id;

});

a_var = JSON.stringify(visRow);

Hey, Andy.

Can you post your code here? Cause it’s not so clear from your explanation what is wrong. Generally, you are right, if you’'l use forEach function, you should have correct outcomes.

Thanks

Ok, I solved my problem with the use of Index to create the output array instead of ID.
The matter is that if you obtain from connector something like this:

row n. 0 - id 5
row n. 1 - id 3
row n. 2 - id 7
row n. 3 - id 1 etc.
usign forEachRow obtain an array whose elements are in order of id:
array[0] -> id 1
array[1] -> id 3
array[2] -> id 5
array[3] -> id 7 etc.
getting the index every cicle of forEachRow avoids that:
array[index = 0] -> id 5
array[index = 1] -> id 3
array[index = 2] -> id 7
array[index = 3] -> id 1
as I wanted to obtain.
so in your code (thanks, anyway) instead of visRow[id] = [ ]
I used

i = Grid_a.getRowIndex(id);
	visRow[i] = [];

that brings to the wanted result

Yea, I see. Good to hear, you solved your problem) Wow, I didn;t enter this forum for years)))