Hi,
I added a sort by default to my grid, but, when I change the order in UI, to descending in the same column, this doesnt work, it sort again in ascending mode because the event OnRowIslandDataBinding fire again (when clickin in the column header)
anyway to fix this?
thanks
protected void OnRowIslandDataBinding (object sender, RowIslandEventArgs e)
{
Sorting sort = e.RowIsland.Behaviors.CreateBehavior<Sorting>();
sort.SortedColumns.Add("columnKey1", Infragistics.Web.UI.SortDirection.Ascending);
}
Hello,
Thank you for contacting Infragistics!
When you sort the row the data is bound again, but sorted. Relatively the DataBinding event is fired again. When the event is fired again the code for creating the behavior is executed again, and you are adding a the same behavior multiple times. You can only have one Sorting behavior.
In other words you can check if there isn't already such behavior.
protected void OnRowIslandDataBinding(object sender, RowIslandEventArgs e) {
if (e.RowIsland.Behaviors.GetBehavior<Sorting>() == null) { Sorting sort = e.RowIsland.Behaviors.CreateBehavior<Sorting>(); sort.SortedColumns.Add("columnKey1", Infragistics.Web.UI.SortDirection.Ascending); } }
perfect, thanks!