forEachRow returns different id order than rendered

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);