I have an UltraWebGrid that automatically sorts by the first displayed column in the grid.
When the grid initially displays, I'd like it to be sorted on the 3rd column. How would I set this up via run time code (not using IDE).
Hi ,I am using Ultrawebgrid, and wanted to do the multi column sorting on the page load.I am doing this in the databound event of the grid.I am using the below codeprotected void UGMedicReview_DataBound(object sender, EventArgs e) { this.UGMedicReview.DisplayLayout.Bands[0].Columns.FromKey("MemberID").SortIndicator = SortIndicator.Descending;this.UGMedicReview.DisplayLayout.Bands[0].Columns.FromKey("Name").SortIndicator = SortIndicator.Descending; UGMedicReview.Bands[0].SortedColumns.Clear();UGMedicReview.Bands[0].SortedColumns.Add(UGMedicReview.Columns.FromKey("MemberID"), true);UGMedicReview.Bands[0].SortedColumns.Add(UGMedicReview.Columns.FromKey("Name"), true); }Let me know how to do this and where I am doing this wrong!!!Thanks
One last note, for anyone who comes along later: I put my code in the Grid.DataBound event handler.
I got the multiple column sorting to work by setting the column.SortIndicator property in the column before adding it to the SortedColumns.
So, my final code looks something like this.
col1 = grid.Columns.FromKey("PrimarySortColumnName"); col.Header.Caption = "Primary Sort Column"; col.SortIndicator = SortIndicator.Ascending; col = grid.Columns.FromKey("SecondarySortColumnName"); col.Header.Caption = "Secondary Sort Column"; col.SortIndicator = SortIndicator.Ascending; grid.Bands[0].SortedColumns.Clear(); grid.Bands[0].SortedColumns.Add(col1, true); grid.Bands[0].SortedColumns.Add(col2, true);
Thanks for the help.
nuhfeken said: Does the UltraWebGrid support multiple column sorting?
Does the UltraWebGrid support multiple column sorting?
Yes. And I don't see anything wrong with your code. Is it possible that your secondary sort column is confused about its datatype? E.G: sorting dates as strings puts "12/30/2001" before "6/17/2008".
Also, you could search this forum for "SortedColumns.Add" and go through everybody else's glitches.
(Sorry, I know that's probably not helpful, but it's all I got. ;-)
Please keep us posted.
This works great for 1 column sorting. Is it possible to sort on multiple columns? I tried adding a separate line but it didn't seem to work for me.
MyGrid.Bands(0).SortedColumns.ClearMyGrid.Bands(0).SortedColumns.Add(MyGrid.Columns.FromKey("MyPrimaryName"), True)MyGrid.Bands(0).SortedColumns.Add(MyGrid.Columns.FromKey("MySecondaryName"), True) Does the UltraWebGrid support multiple column sorting?
MyGrid.Bands(0).SortedColumns.ClearMyGrid.Bands(0).SortedColumns.Add(MyGrid.Columns.FromKey("MyPrimaryName"), True)
MyGrid.Bands(0).SortedColumns.Add(MyGrid.Columns.FromKey("MySecondaryName"), True)