[Index.cshtml]
@Html.EJS().Grid("Grid").AllowPaging().Load("Load").DataSource(ds => { ds.Url("/Home/UrlDatasource").Adaptor("UrlAdaptor"); }).Columns(col =>
{
. . . .
}).AllowPaging().PageSettings(page => page.PageSize(15).PageCount(10)).Render()
<script>
document.getElementById("btnViewReport").addEventListener("click", function () {
var gridObj = document.getElementById("Grid").ej2_instances[0];
gridObj.showSpinner(); // show the spinner
var Ajax = new ej.base.Ajax({
type: "POST",
url: "/Home/getDate",
contentType: "application/json; charset=utf-8",
});
Ajax.send();
Ajax.onSuccess = function (result) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
var data = new ej.data.DataUtil.parse.parseJson(result);
gridObj.dataSource = data;
gridObj.hideSpinner(); // We have hide the spinner while bind data in Grid
};
Ajax.onFailure = function (data) {
}
}) |
[index.cshtml]
document.getElementById("btnViewReport").addEventListener("click", function () {
var gridObj = document.getElementById("Grid").ej2_instances[0];
gridObj.showSpinner();
var Ajax = new ej.base.Ajax({
type: "POST",
url: "/Home/getDate",
contentType: "application/json; charset=utf-8",
data: JSON.stringify([{ memberGroupId: 1 }])
});
Ajax.send();
Ajax.onSuccess = function (result) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
var data = new ej.data.DataUtil.parse.parseJson(result);
gridObj.dataSource = data;
gridObj.hideSpinner();
};
Ajax.onFailure = function (data) {
}
})
[HomeController.cs]
public ActionResult getDate(List<memberGroup> id)
{
. . . .
return Json(order);
}
public class memberGroup {
public int memberGroupId { get; set; }
}
|