namespace MvcApplication66.Controllers
{
public class HomeController : Controller
{
public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm)
{
IEnumerable datasource = new NorthwindDataContext().EmployeeViews.ToList();
DataResult result = new DataResult();
DataOperations operation = new DataOperations();
. . .. . .
List<string> str1 = new List<string>();
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);
}
if (dm.Group != null) {
for (var i = 0; i < dm.Group.Count; i++)
str1.Add(dm.Group[i]);
result.groupDs = operation.PerformSelect(DataSource, str1);
if (dm.Aggregates != null)
{
for (var i = 0; i < dm.Aggregates.Count; i++) {
if(str1.IndexOf(dm.Aggregates[i].Field)==-1)
str1.Add(dm.Aggregates[i].Field);
}
result.groupDs = operation.PerformSelect(DataSource, str1);
}
}
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; }
public IEnumerable groupDs { get; set; }
}
<div id="Grid"></div>
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
dataSource: ej.DataManager({
url: "/Home/DataSource",
adaptor: new ej.UrlAdaptor()
}),
summaryRows: [
{ title: "Sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight", format: "{0:C2}" }] },
. .
],
});
});
</script> |