using System.Collections.Generic;
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 _flexGridDisableServerReadModel = new GridExportImportOptions
{
NeedExport = true,
NeedImport = false,
IncludeColumnHeaders = true
};
private readonly ControlOptions _disableServerReadSetting = new ControlOptions
{
Options = new OptionDictionary
{
{"Disable Server Read",new OptionItem{Values = new List<string> {"True", "False"},CurrentValue = "True"}}
}
};
public IActionResult DisableServerRead(IFormCollection collection)
{
_disableServerReadSetting.LoadPostData(collection);
ViewBag.DemoOptions = _disableServerReadSetting;
ViewBag.Options = _flexGridDisableServerReadModel;
return View();
}
public ActionResult DisableServerRead_Bind([C1JsonRequest] CollectionViewRequest<Sale> requestData)
{
return this.C1Json(CollectionViewHelper.Read(requestData, Sale.GetData(500)));
}
}
}
@{
ControlOptions optionsModel = ViewBag.DemoOptions;
GridExportImportOptions exportOptionsModel = ViewBag.Options;
ViewBag.DemoSettings = true;
}
<c1-flex-grid id="@exportOptionsModel.ControlId" auto-generate-columns="true" class="grid" is-read-only="true">
<c1-flex-grid-filter></c1-flex-grid-filter>
<c1-items-source disable-server-read="@(Convert.ToBoolean(optionsModel.Options["Disable Server Read"].CurrentValue))"
initial-items-count="10"
read-action-url="@Url.Action("DisableServerRead_Bind")"></c1-items-source>
</c1-flex-grid>
@section Settings{
<p>@await Html.PartialAsync("_OptionsMenu", optionsModel)</p>
<p>@await Html.PartialAsync("_FlexGridOptions", exportOptionsModel)</p>
}
@section Description{
@Html.Raw(MVCFlexGrid.DisableServerRead_Text0)
}