/// <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> /// Sets the pager related properties of the specified <see cref="SmartView"/>. /// </summary> /// <remarks> /// The pager related properties like PageSize, PagerSettings.Mode, /// PagerSettings.PageButtonCount and PagerSettings.Position are set. /// </remarks> /// <param name="view">The <see cref="SmartView"/>, the pager /// related properties of which are to set.</param> /// <param name="p">The parameters used to set the properties. Currently not being used.</param> public void InitService(SmartView view, params object[] p) { view.PageSize = (view.PageSize == 10) ? DefaultPageSize : view.PageSize; // view.PagerSettings.Visible = view.AllowPaging; if (DefaultPagerMode == PagerMode.NumericPages) view.PagerSettings.Mode = PagerButtons.NumericFirstLast; if (DefaultPagerMode == PagerMode.NextPrev) view.PagerSettings.Mode = PagerButtons.NextPreviousFirstLast; view.PagerSettings.PageButtonCount = 10; view.PagerSettings.Position = PagerPosition.Bottom; }
/// <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(); }
/// <summary> /// Puts the specified <see cref="SmartView"/> into the /// <see cref="StateManager.Personal"/> i.e. session. /// </summary> /// <param name="view">The <see cref="SmartView"/> to put.</param> /// <param name="p">The parameters to use. Currently not being used.</param> public void InitService(SmartView view, params object[] p) { Grid = view; }