Epic Puck

16 Dec

Code: Infragistics and Sorting Ultrawebgrid

Posted in c#, coding, javascript, personal No comment

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.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Live
  • StumbleUpon
  • e-mail
  • Slashdot
  • Technorati
Written on December 16 2009 and is filed under c#, coding, javascript, personal. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.

Designed by Gabfire brought to you by PS3, PSP and GTA 4; RE-Designed by Puck

© 2010 Epic Puck | World of Warcraft and Blizzard are Trademarks of Blizzard Entertainment.
Game Images, Screenshots, Chat Logs or Portions Thereof are Sole Property of Blizzard Entertainment and Are Used with Permission through the Terms of Service and End User License Agreement.