How can i export the grid data to CSV?

How can i export the grid data to CSV?

i am using below code

var file=mygrid.serializeToCSV() ;

    alert(file);



but it only shows the last row multiple times , i need all rows data to export

The command is correct and must return data from all rows in grid.
Please be sure that each row has unique ID , the problem may be caused by missed|non-unique row IDs.