@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).InsertURL("/Grid/PerformInsert")
.UpdateURL("/Grid/PerformUpdate")
.RemoveURL("/Grid/PerformDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
…
}).ClientSideEvents(eve=>eve.QueryCellInfo("querycellinfo")))
<script type="text/javascript">
function querycellinfo(args) {
if (args.column.field == "TotalPrice") {
$(args.cell).text(args.data.EmployeeID * args.data.Freight);//For display purpose
}
}
</script> |
ALTER TABLE dbo.OrderTables DROP COLUMN TotalPrice;
GO
ALTER TABLE dbo.OrderTables ADD TotalPrice AS (EmployeeID * Freight ); |
<div>
TotalPrice: <input id="TotalFreight" type="text" width="200" />
</div>
@(Html.EJ().Grid<object>("FlatGrid")
..
.Columns(col =>
{
..
col.Field("TotalPrice").HeaderText("TotalPrice").Width(80).Add();
col.Field("OrderDate").HeaderText("Order
}).ClientSideEvents(eve=>eve.DataBound("databound").ActionComplete("actioncomplete")))
<script type="text/javascript">
var total = 0;
function databound(args) {
total = ej.sum(this.model.dataSource.dataSource.json, "TotalPrice");
$("#TotalFreight").val(total);
}
function actioncomplete(args) {
if (args.requestType == "save" || args.requestType == "delete") {
total = ej.sum(this.model.dataSource.dataSource.json, "TotalPrice"); // here we have calculated summary for whole dataSource , if you want to display summary for current page only means use
this. model.currentViewData
$("#TotalFreight").val(total);
}
}
</script> |