Can't select first row after sorting

I’m trying to select first row after grid sorting using the following code

[code]function init(){

dhtmlx.image_path='./codebase/imgs/';

var main_layout = new dhtmlXLayoutObject({
	parent:  document.body,
    pattern: "1C",
    cells: [{id: "a"}]
});

var selectionGrig = main_layout.cells('a').attachGrid();

with (selectionGrig){
	attachEvent("onAfterSorting", function(index,type,direction){selectionGrig.selectRow(0);});
	setIconsPath('./codebase/imgs/');
	setHeader("Show,Group,Date,Time,C1,S,C2,L,H");
	setColTypes("ch,ro,dhxCalendar,ro,coro,ro,ro,ro,ro");
	setColSorting('int,int,date,time,int,str,int,str,int');
	setDateFormat('%d %M %Y','%Y-%m-%d');
	updateFromXML('./data/tmp.xml', true,false, function(){selectionGrig.groupBy(1);});
	init();
}

}[/code]

but it select always the same row after sorting whatever the position of this row but not the first one.

You may call:

 attachEvent("onAfterSorting", function(index,type,direction){selectionGrig.selectRow(selectionGrig.rowsCol[1]);});