<div id="Grid"></div>
<script type="text/babel">
$(function(){
var data = ej.DataManager({url: "/Grid/DataSource", adaptor:"UrlAdaptor"});
var settings = { width: 550, height: 300, enableVirtualization: true };
ReactDOM.render(
<div id="Grid2">
<table>
<tr>
<td>
<EJ.Grid id="Grid_1" dataSource={data} allowScrolling={true} allowSorting={true} scrollSettings={settings}>
<columns>
………………………………………………………………………………..
</columns>
</EJ.Grid>
</td>
</tr>
</table>
</div>,
document.getElementById('Grid')
);
});
</script>
public IEnumerable OrderData = new NorthwindDataContext().OrdersViews.ToList();
public ActionResult DataSource(DataManager dataManager)
{
IEnumerable data = OrderData;
DataOperations operation = new DataOperations();
if (dataManager.Sorted != null && dataManager.Sorted.Count > 0) //Sorting
{
data = operation.PerformSorting(data, dataManager.Sorted);
}
if (dataManager.Where != null && dataManager.Where.Count > 0) //Filtering
{
data = operation.PerformWhereFilter(data, dataManager.Where, dataManager.Where[0].Operator);
}
int count = data.Cast<OrdersView>().Count();
if (dataManager.Skip != 0)
{
data = operation.PerformSkip(data, dataManager.Skip);
}
if (dataManager.Take != 0)
{
data = operation.PerformTake(data, dataManager.Take);
}
return Json(new { result = data, count = count });
}
|