@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.
.
.
.EditSettings(edit=>{edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ClientSideEvents(e => e.QueryCellInfo("QueryCellInfo"))
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add();
col.Field("ShipCity").HeaderText("Ship City").Width(110).Add();
}))
</div>
<script>
function QueryCellInfo(args) {
if (args.column.field == "Freight" && args.data.Freight < 0) {
args.cell.innerHTML = "-" + ej.format(args.data.Freight * -1, "C2");
}
}
</script>
|