Is there any way to set the initial sort column for a WebGrid (say during the Page_Load event when I bind it to the data source), such that the grid first appears pre-sorted with the SortIndicator graphic showing in the appropriate column, without the user having the sort manually?
LarsNielsen said:I presume if you just change the SortIndicator that won't acually re-order the items,
Your assumption is logical enough, but incorrect. (Call it "Infragistics Quirk #17") Change the line to:
col.SortIndicator = Infragistics.WebUI.UltraWebGrid.SortIndicator.Descending
Caveat: sorting your underlying data (e.g. "ORDER BY" in SQL) will probably prove more efficient and faster.
Thanks very much for that. Can I set it to sort by descending order rather than ascending? I presume if you just change the SortIndicator that won't acually re-order the items, but I can't see any other place to specify the sort order?
In the Grid.DataBound hander (Page.Load may not always work):
'Sort by OrderIDOrdersUltraWebGrid.Bands(0).SortedColumns.Clear()Dim col As Infragistics.WebUI.UltraWebGrid.UltraGridColumn = _ Me.OrdersUltraWebGrid.Bands(0).Columns.FromKey("CustomerId")col.SortIndicator = Infragistics.WebUI.UltraWebGrid.SortIndicator.AscendingOrdersUltraWebGrid.Bands(0).SortedColumns.Add(col, True)
See also: http://news.infragistics.com/forums/p/9193/51704.aspx#51704