@(Html.EJ().Grid<object>("Grid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("/Home/Update").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.InlineForm); })
..
)
|
<script id="templateData" type="text/x-jsrender">
Freight has Average of {{:summaryValue}} in dollars
</script>
@(Html.EJ().Grid<object>("Grid")
.. .SummaryRow(row =>
{
row.ShowTotalSummary(false)
.SummaryColumns(col =>
{
col.SummaryType(SummaryType.Sum)
.DisplayColumn("Freight")
.DataMember("Freight")
.Prefix("Sum = ")
.Template("#templateData")
.Add();
}).Add();
})
.GroupSettings(group => { group.GroupedColumns(col => { col.Add("OrderID"); }); })
..
|
@(Html.EJ().Grid<object>("Grid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("/Home/Update").Adaptor(AdaptorType.RemoteSaveAdaptor))
..
.GroupSettings(group => { group.GroupedColumns(col => { col.Add("OrderID"); }); })
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(80).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(80).Add();
col.Field("OrderDate").HeaderText("Order Date").AllowEditing(false).Format("{0:MM/dd/yyyy}").Add();
col.Field("ShipCity").HeaderText("Ship City").Width(90).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(80).Format("{0:C}").Add();
}).ClientSideEvents(eve=>eve.Load("load"))
)
<script type="text/javascript">
function load(args){
var len = this.model.dataSource.dataSource.json.length;
for (var i = 0; i < len; i++) {
ej.createObject("OrderDate", new Date(this.model.dataSource.dataSource.json[i].OrderDate), this.model.dataSource.dataSource.json[i]) //convert the date string to date object
}
}
</script> |