@{
ViewBag.Title = "Home Page";
}
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds =>
ds.URL("http://services.odata.org/V4/Northwind/Northwind.svc/Orders")
.Adaptor(AdaptorType.ODataV4Adaptor))
.AllowFiltering()
.FilterSettings(filter => { filter.FilterType(FilterType.Menu); })
.AllowSorting()
.SortSettings(b =>
b.SortedColumns(col =>
col.Field("Customer.CompanyName")
.Direction(SortOrder.Ascending).Add())
)
.AllowPaging()
.AllowSelection(false)
.EnableRowHover(false)
.Query("new ej.Query().select(['OrderID']).expand(['Customer($select=CompanyName)'])")
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Add();
col.Field("Customer.CompanyName").HeaderText("Company Name").Add();
})
)
<script>
var onEachSort = ej.ODataV4Adaptor.prototype.onEachSort;
ej.ODataV4Adaptor.prototype.onEachSort = function (e) {
var res = [];
if (!(e.name instanceof Array) && e.name.split(".").length > 1) {
res.push(this._p(e.name) + (e.direction === "descending" ? " desc" : ""));
return res.join(",");
}
return onEachSort.apply(this, [e]);
};