ALTER TABLE dbo.OrderTables DROP COLUMN TotalPrice;
GO
ALTER TABLE dbo.OrderTables ADD TotalPrice AS (EmployeeID * Freight ); |
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.dataSource)
.AllowPaging()
.ShowSummary()
.SummaryRow(row =>
{
row.Title("Sum")
.SummaryColumns(col => {
col.SummaryType(SummaryType.Custom)
.CustomSummaryValue("customValue")
.Format("{0:C}")
.DisplayColumn("TotalPrice")
.DataMember("TotalPrice")
.Add();
}).Add();
})
.. . .
.Columns(col =>
{
. . . .
. . .
col.Field("TotalPrice").HeaderText("TotalPrice")
.Template("<span class='total'>{{:Freight * EmployeeID }}</span>")
.AllowEditing(false)
.Add();
})
)
<script type="text/javascript">
function customValue(summaryCol, summaryData) {
var summaryData1 = 0;
var json = summaryData;
for (var j = 0; j < json.length; j++) {
summaryData1 += json[j].EmployeeID * json[j].Freight;
}
//summaryData parameter - returns the corresponding dataSource
return summaryData1;
}
</script> |