using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using C1.Web.Mvc;
using C1.Web.Mvc.Serialization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WebApiExplorer.Models;
namespace WebApiExplorer.Controllers
{
public partial class MVCFlexGridController : Controller
{
private readonly GridExportImportOptions _flexGridPagingModel = new GridExportImportOptions
{
NeedExport = true,
NeedImport = false,
OnlyCurrentPage = false,
IncludeColumnHeaders = true
};
private readonly ControlOptions _gridPagingModel = new ControlOptions
{
Options = new OptionDictionary
{
{"Page Size", new OptionItem {Values = new List<string> {"10", "25", "50", "100"}, CurrentValue = "25"}},
}
};
public IActionResult Paging(IFormCollection data)
{
_gridPagingModel.LoadPostData(data);
ViewBag.DemoOptions = _gridPagingModel;
ViewBag.Options = _flexGridPagingModel;
return View();
}
public ActionResult Paging_Bind([C1JsonRequest] CollectionViewRequest<Sale> requestData)
{
return this.C1Json(CollectionViewHelper.Read(requestData, Sale.GetData(500)));
}
}
}
@{
GridExportImportOptions exportOptionsModel = ViewBag.Options;
ControlOptions optionsModel = ViewBag.DemoOptions;
ViewBag.DemoSettings = true;
}
<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="@exportOptionsModel.ControlId" class="customGrid"
is-read-only="true" items-source-id="collectionViewService">
</c1-flex-grid>
<c1-pager owner="@exportOptionsModel.ControlId"></c1-pager>
@section Settings{
@await Html.PartialAsync("_OptionsMenu", optionsModel)
@await Html.PartialAsync("_FlexGridOptions", exportOptionsModel)
}
@section Description{
<p>@Html.Raw(MVCFlexGrid.Paging_Text0)</p>
}