Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Harish on Mar 11, 2008 06:24
open dhtmlx forum
Sorting issue after refresh


Hi,

After sorting the DhtmlxGrid by clicking on one of the headers, and clicks on one of the button in the grid, where i am doing a database update, the page refreshes back to unsorted.

The button click is like this

function gridButtonClicked(target,argument )
{
__doPostBack(''+target,''+argument);
}

this is how i am setting the button

WriteSearchResultsCell(writer, "<img src=\"../images/icn_lock.gif\" style=\"cursor:hand; border:0px;\" alt=\"" + objCheckoutUser.FirstName + " " + objCheckoutUser.LastName + " Checked out at " + objRequest.CheckoutTime.ToString() + "\" onclick = \"gridButtonClicked('Lock#Edit' ,'" + objRequest.RequestID + "')\" />", true);

I want the DhtmlxGrid should remain sorted after the page refreshes .Please help me.

Thank you in advance.

Harish
Answer posted by Sorting on Mar 12, 2008 05:10
What grid version do use ?

The professional version provides API to do it:

    grid.saveSortingToCookie(); 
    grid.loadSortingFromCookie();

In case of standard version you can use getSortingState method. It returns the array  where first element is column index  and the second - state.

    var sorting_array = grid.getSortingState();

And after getting these value from cookie you can  do  following:
 
    grid.sortRows(column_index,null,state);

    grid.setSortImgState(true,column_index,state);