@(Html.EJ().Grid<SyncfusionMvcApplication7.Models.ModelT>("GridContainer")
.Datasource(ds => ds.URL("/home/DataSource").Adaptor("UrlAdaptor"))
.Query(queryString)
..
.Columns(col =>
{
col.Field("ModelTID").HeaderText("ID").IsPrimaryKey(true).IsIdentity(true).Visible(false).Add();
col.Field("Name").HeaderText("Name").Add();
col.Field("Age").HeaderText("Age").EditType(EditingType.Numeric).Add();
col.Field("Date").HeaderText("Date").Add();
})
)
HomeController.cs
public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm)
{
IEnumerable Data = new NORTHWNDEntities().C30000Records.ToList();
Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations();
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
Data = operation.PerformSorting(Data, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
Data = operation.PerformWhereFilter(Data, dm.Where, dm.Where[0].Operator);
}
if (dm.Search != null && dm.Search.Count > 0) //searching
{
Data = operation.PerformSearching(Data, dm.Search);
}
int count = Data.AsQueryable().Count();
if (dm.Skip != 0)
{
Data = operation.PerformSkip(Data, dm.Skip);
}
if (dm.Take != 0)
{
Data = operation.PerformTake(Data, dm.Take);
}
return Json(new { result = Data, count = count }, JsonRequestBehavior.AllowGet);
}
|