FlexGrid
Remote Data Bind
Features
Sample AriaLabel:
Description
This example shows how you can bind FlexGrid with the data from some Action.
This example also demos how you can set ariaLabel to the grid control.
Source
RemoteBindController.cs
using System.Web.Mvc; using MvcExplorer.Models; using C1.Web.Mvc; using C1.Web.Mvc.Serialization; namespace MvcExplorer.Controllers { public partial class FlexGridController : Controller { public ActionResult RemoteBind_Read([C1JsonRequest] CollectionViewRequest<Sale> requestData) { return this.C1Json(CollectionViewHelper.Read(requestData, Sale.GetData(500))); } public ActionResult RemoteBind() { return View(); } } }
RemoteBind.cshtml
@using C1.Web.Mvc.Grid @(Html.C1().FlexGrid().Id("remoteGrid") .AutoGenerateColumns(false) .SortingType(AllowSorting.SingleColumn) .IsReadOnly(true) .Bind(Url.Action("RemoteBind_Read")) .CssClass("grid") .SelectionMode(SelectionMode.Row) .AriaLabel("This is a FlexGrid of Sale.") .Columns(columns => { columns.Add(column => column.Binding("ID").Visible(false)); columns.Add(column => column.Binding("Start").Format("MMM d yy")); columns.Add(column => column.Binding("End").Format("HH:mm")); columns.Add(column => column.Binding("Country")); columns.Add(column => column.Binding("Product")); columns.Add(column => column.Binding("Color")); columns.Add(column => column.Binding("Amount").Format("c")); columns.Add(column => column.Binding("Amount2").Format("c")); columns.Add(column => column.Binding("Discount").Format("p0")); columns.Add(column => column.Binding("Active")); }) ) <p></p> AriaLabel:<input type="text" style="width:500px" id="txtLabel" value="This is a FlexGrid of Sale." /> <input type="button" class="btn" onclick="applyAriaLabel()" value="Apply" /> @section Scripts{ <script> function applyAriaLabel() { var ariaLabel = document.getElementById("txtLabel").value; if (ariaLabel != "") { var control = wijmo.Control.getControl("#remoteGrid"); if (control) { control.ariaLabel = ariaLabel; control.invalidate(); } } } </script> } @section Description{ <p>@Html.Raw(Resources.FlexGrid.RemoteBind_Text0)</p> <p>@Html.Raw(Resources.FlexGrid.RemoteBind_Text1)</p> }
Documentation