Sorting header columns not work fine

Hi to all,
unfortunately is happening to me a problem with a grid DHTMLX with sorting of the columns , the grid and the sorting of the columns is created properly, but at first click on the header for to start the sorting colums,the page returns me to the top, scrolling down return on header of table and click again and the visual remains on the grid without problem and perfect sorting .
You know someone explain to me the reason of the first click on header returned on top page and how to resolve it ?
the sortig code that I use is the following :
grid.setColSorting(“int,str,na,str”).

Thanks so much.

Hey,

on grid creation you have to set the initial sort with:

myGrid.setSortImgState(true,0);

http://docs.dhtmlx.com/api__dhtmlxgrid_setsortimgstate.html

otherwise the first click on the grid header will just do nothing, except from scroll to the very top of your grid.

Thank you so much for your answer.
I tried the code you suggested but I have another error
this.hdr.rows [0] is undefined

by chance you know what it depends on?

I tried with
myGrid.setSortImgState (true, 0);

and also as documentation with
myGrid.setSortImgState (true, 1);

but still the same error
this.hdr.rows [0] is undefined

Thanks again

Please, make sure that you are calling the setSortImgState() method after the grid is initialized.

yes, but result not change.
I also tried this but the first click always goes to the top page.

this my code:
var myGrid = new dhtmlXGridObject(“table”);
myGrid.setHeader(my fuction for json);
myGrid.enableAutoWidth(true);
myGrid.enableAutoHeight(true);
myGrid.setColAlign(“left,left,left,left,left,left,middle,middle,middle”);
myGrid.setInitWidthsP(“10,14,10,10,10,10,12,12,12”);
myGrid.setColTypes(“ro,ro,ro,ro,ro,ro,ro,ro,ro”);
myGrid.init();
myGrid.parse(data,“json”);
myGrid.setSortImgState(true,0);
myGrid.setColSorting(“date,str,money_sort,money_sort,date,str,na,na,na”);

This problem I have only on browser FireFox with Chrome grid.setSortImgState(true,0); worked fine.

How I can resolve it?

Thanks!

Please, try to define the column sorting before the init of the grid.
if the problem still occurs for you please, provide with a complete demo, where the problem can be reconstructed locally.