Code: Infragistics and Sorting Ultrawebgrid
by Geoff on Dec.16, 2009, under c#, Coding, javascript, Personal
I know a lot of my subscribers are not coders. Nonetheless I would like to put this bit of code out there.
The sorting problem would occur if the grid was sorted normally. That is, you set the single column you wish to sort the grid on and use the following code client side:
var r_grid=igtbl_getGridById('< %=gridName.columnName%>');
r_grid.addSortColumn("gridName_c_0_0", true);
r_grid.sort();
The problem with this call is that the Ultrawebgrid does not retain the sorting order of the column. The Ultrawebgrid control will then flip the sorting order when the above is called client side.
This code is the fix:
var r_grid=igtbl_getGridById('< %=gridName.ClientID%>');
var sortColId = r_grid.Bands[0].getColumnFromKey("columnName").Id // ID of column to sort grid by
r_grid.Bands[0].getColumnFromKey("columnName").SortIndicator = 0; // Make it think it's unsorted
r_grid.sortColumn(sortColId, false);
if (r_grid.Bands[0].getColumnFromKey("columnName").SortIndicator = 0)
{
r_grid.addSortColumn("gridName_c_0_0", true);
r_grid.sort();
}
I hope it helps you like it did me.

