FlexGrid
Paging
Features
Sample
Settings
Description
This sample shows how to implement paged views with the FlexGrid. All the work is done by the CollectionView class used as a data source for the grid. To enable paging, set the PageSize property of FlexGrid or CollectionViewService. To switch pages, use the Pager Control and set Pager.Owner property to the id of FlexGrid or CollectionViewService.
Note: That the paging UI is implemented outside of the grid. This gives you complete control over the appearance and functionality of the paging mechanism. To customize the Pager by Javascript, please refer the client CollectionView class.
Source
PagingController.cs
using C1.Web.Mvc; using C1.Web.Mvc.Serialization; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using MvcExplorer.Models; using Microsoft.AspNetCore.Http; namespace MvcExplorer.Controllers { public partial class FlexGridController : Controller { private readonly ControlOptions _gridPagingModel = new ControlOptions { Options = new OptionDictionary { {"Page Size", new OptionItem {Values = new List<string> {"10", "25", "50", "100"}, CurrentValue = "25"}}, } }; public ActionResult Paging(IFormCollection data) { _gridPagingModel.LoadPostData(data); ViewBag.DemoOptions = _gridPagingModel; return View(); } public ActionResult Paging_Bind([C1JsonRequest] CollectionViewRequest<Sale> requestData) { return this.C1Json(CollectionViewHelper.Read(requestData, Sale.GetData(500))); } } }
Paging.cshtml
@model IEnumerable<Sale> @{ ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true; } @section Styles{ <style> .customGrid { margin-top: 5px; } </style> } <c1-items-source id="collectionViewService" read-action-url="@Url.Action("Paging_Bind")" page-size="@Convert.ToInt32(optionsModel.Options["PageSize"].CurrentValue)"></c1-items-source> <c1-pager owner="collectionViewService"></c1-pager> <c1-flex-grid height="300px" id="pagingGrid" class="customGrid" is-read-only="true" items-source-id="collectionViewService"> </c1-flex-grid> <c1-pager owner="pagingGrid"></c1-pager> @section Settings{ @await Html.PartialAsync("_OptionsMenu", optionsModel) } @section Description{ <p>@Html.Raw(FlexGridRes.Paging_Text0)</p> <p>@Html.Raw(FlexGridRes.Paging_Text1)</p> }
Documentation