|
GridFeatures.cshtml]
@(Html.EJ().Grid<object>("Grid")
.Datasource(ds => ds.URL("/Grid/UrlDataSource").Adaptor("UrlAdaptor"))
...
.Columns(col =>
{
...
.ClientSideEvents(eve => eve.ActionBegin("onActionBegin"))
)
<script>
function onActionBegin(args) {
if (args.requestType == "filterchoicerequest") {
//selects only the filtering column
//which prevents the serialization errror.
args.query.select(args.filterModel.fName);
}
}
</script>
-----------------------------------------------------------
[GridController.cs]
public ActionResult UrlDataSource(DataManager dm)
{
BindDataSource();
IEnumerable data = order;
DataOperations operation = new DataOperations();
-----
if (dm.Select != null)
{
data = operation.PerformSelect(data, dm.Select);
data = data.Cast<dynamic>().Distinct().AsEnumerable();
}
if (dm.Skip != 0)
{
data = operation.PerformSkip(data, dm.Skip);
}
if (dm.Take != 0)
{
data = operation.PerformTake(data, dm.Take);
}
if (dm.RequiresCounts )
return Json(new { result = data, count = count });
else
return Json(data, JsonRequestBehavior.AllowGet);
}
|