Indicating initial sort state for a listgrid

In our application, we are dynamically constructing listgrids and initializing them with sorted data. What is the recommended means of conveying the initial sort order to the client engine so that the sort indicator is correctly set? For example, we may initialize the listgrid such that the 5th column is sorted in descending order and would like to have the down arrow initially displayed on that column.

We are using JSF edition 4.2. In 4.0, we would add a DeltaActionCallMethod to invoke setColumnSortState. In 4.2, it is a little more complicated because we also need to indicate that the listgrid is sortable so our current scheme is a clumsy series of actions:
1) DeltaActionSetAttribute to set sortField
2) DeltaActionSetAttribute to set sortDirection
3) DeltaActionSetProperty to set sorted property
4) DeltaActionCallMethod to invoke setColumnSortState

1+2 mark the listgrid as sortable, 3 indicates it is sorted, and 4 causes the sort indicator to be displayed.

Indicating initial sort state for a listgrid

Hi Steve,
could you try use sortColumn method with column index you want to sort and execute the method in the "pageRefreshed" event?

this.sortColumn(2); // column 2 is sorted

~Yudi

Thanks for the hint Yudi.

Thanks for the hint Yudi. That sort of works except that the client makes a call to the server to perform a sort each time it is refreshed. This is ususally not a huge deal, but our application polls so this ends up generating an extra call every 5 seconds or so.

The solution I've implemented (and it seems to work well) is to have the server add an event handler for DOMNodeInsertedIntoDocument as verbatim text. This handler performs the four steps listed previously. Whenever the user sorts the listgrid, this verbatim text is updated with the new column and direction values so that when the listgrid re-enters the UI or the browser is refreshed, its sort indicators are correctly set.