@Html.EJ().Button("ClickMe").Text("Populate Grid Content").ClientSideEvents(e => e.Click("btnClick"))
@(Html.EJ().Grid<MvcApplication66.OrdersView>("FlatGrid")
.AllowPaging()
.Columns(col =>
{
col.Field("OrderID").Add();
col.Field("CustomerID").Add();
col.Field("EmployeeID").Add();
col.Field("OrderDate").Format("{0:MM/dd/yyyy}").Add();
col.Field("Freight").Format("{0:C3}").Add();
})
)
<script>
function btnClick(args) {
$.ajax({
type: "POST",
url: "/Home/Data/",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var formatData = ej.parseJSON(data); //after success, parsing the data to convert the date Object
//$("#FlatGrid").ejGrid({ dataSource: formatData }); //updating the dataSource through setModel
var gridObj = $("#FlatGrid").ejGrid("instance");
gridObj.dataSource(formatData);//dataSource method
}
});
}
</script>
public ActionResult Data()
{
var data = new NorthwindDataContext().OrdersViews.ToList();
return Json(data);
} |
var pivotGrid = $("#PivotGrid1").data("ejPivotGrid");
pivotGrid.model.dataSource.data = pivot_dataset_refresh;
pivotGrid._populatePivotGrid();
<script>
function btnClick(args) {
$.ajax({
type: "POST",
url: "/Grid/Data",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var formatData = ej.parseJSON(data);
var gridObj = $("#FlatGrid").ejGrid("instance");
var query = ej.Query().sortBy("ShipCity", ej.sortOrder.Ascending, false);
var dataManager = ej.DataManager(formatData).executeLocal(query);
gridObj.dataSource(formatData);//dataSource method
}
});
}
</script> |