/// <summary> /// Sets the new page as the current page of the specified <see cref="SmartView"/>. /// </summary> /// <param name="action">The 'Paging' <see cref="GridAction"/> to perform.</param> /// <param name="view">The <see cref="SmartView"/>, the current page of /// which is to set.</param> /// <param name="p">The parameters used to set the current page.</param> public void HandleService(GridAction action, SmartView view, params object[] p) { if (view == null) return; if (!view.AllowPaging) return; if (action != GridAction.Paging) return; GridViewPageEventArgs args = p[0] as GridViewPageEventArgs; if (args == null) return; view.PageIndex = args.NewPageIndex; view.SelectedIndex = -1; view.DataBind(); }
/// <summary> /// Sorts the records in the specified <see cref="SmartView"/>. /// </summary> /// <param name="action">The 'Sorting' <see cref="GridAction"/> to perform.</param> /// <param name="view">The <see cref="SmartView"/> to sort.</param> /// <param name="p">The parameters used for sorting.</param> public void HandleService(GridAction action, SmartView view, params object[] p) { if (view == null) return; if (!view.AllowSorting) return; if (action != GridAction.Sorting) return; // Handle sorting GridViewSortEventArgs args = p[0] as GridViewSortEventArgs; if (args == null) return; if (args.SortExpression == LastExpression) { SortAscending = !SortAscending; } else { SortAscending = true; LastExpression = args.SortExpression; } args.SortDirection = SortDirection; if (view.DataSource is IDomainCollection) { IDomainCollection col = (IDomainCollection)view.DataSource; col.Sort(args.SortExpression, (args.SortDirection == SortDirection.Ascending) ? SortOrder.Ascending : SortOrder.Descending); view.DataSource = col; } view.DataBind(); }