[index.cshtml]
<ejs-button id="dataSourceUpdate" content="UpdateDataSource"></ejs-button>
<ejs-grid id="Grid" allowPaging="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<e-data-manager url="/Home/GridDatasource" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/Delete" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog"></e-grid-editSettings>
<e-grid-pagesettings pageSize="7"></e-grid-pagesettings>
<e-grid-columns>
-----
</e-grid-columns>
</ejs-grid>
<script>
document.getElementById("dataSourceUpdate").addEventListener('click', function (args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
gridObj.dataSource = @Html.Raw(Json.Serialize(ViewBag.datasource));
});
</script>
|
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{
System.Collections.IEnumerable data = OrdersDetails.GetAllRecords();
DataOperations operation = new DataOperations();
. . . .
return dm.RequiresCounts ? Json(new { result = data, count = count }) : Json(data) ;
} |