@(Html.EJ().Grid<object>("Grid")
.Datasource(ds =>
ds.URL("/Home/DataSource")
.Adaptor(AdaptorType.UrlAdaptor))
.AllowPaging()
.ShowSummary()
.SummaryRow(row =>
{
row.Title("Totals")
.SummaryColumns(col => {
col.SummaryType(SummaryType.Sum)
.Format("{0:N}")
.DisplayColumn("Freight")
.DataMember("Freight").Add();
}).Add();
})
. . .
)
public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm)
{
IEnumerable datasource = new NorthwindDataContext().OrdersViews.ToList();
DataResult result = new DataResult();
DataOperations operation = new DataOperations();
List<string> str = new List<string>();
if (dm.Aggregates != null)
{
for (var i = 0; i < dm.Aggregates.Count; i++)
str.Add(dm.Aggregates[i].Field);
result.aggregate = operation.PerformSelect(datasource, str);
}
int count = datasource.AsQueryable().Count();
. .
. . .
result.count = count;
result.result = datasource;
return Json(result, JsonRequestBehavior.AllowGet);
}
public class DataResult {
public IEnumerable result { get; set; }
public int count { get; set; }
public IEnumerable aggregate { get; set; }
} |