<div class="row"> <div ej-grid id="Grid" e-width="500px" e-datasource="data" e-pagesettings-pagesize="3" e-allowsorting="true" e-allowfiltering="true" e-allowpaging="true" e-editsettings-allowadding="true" e-editsettings-allowdeleting="true" e-editsettings-allowediting="true" e-editsettings-showconfirmdialog="false" e-toolbarsettings-showtoolbar="true" e-toolbarsettings-toolbaritems="tools" e-locale="es-ES" e-showcolumnchooser="true"> <div e-columns> <div e-column e-field="EmployeeID" e-headertext="Employee ID" e-isprimarykey="true" e-textAlign="right"></div> <div e-column e-field="Name" e-headertext="Employee Name" e-textalign="right"></div> </div> </div> </div> <script> angular.module("GridCtrl", ["ejangular"]) .controller("bodyCtrl", function ($scope) { //Provide the datasource to the grid. Here the WebApiAdaptor is used. var camelCaseWebApiAdaptor = new ej.WebApiAdaptor().extend({ processResponse: function (data, ds, query, xhr, request, changes) { for (var i = 0; i < data.items.length; i++) { var a = data.items[i]; for (var key in a) { var temp; if (a.hasOwnProperty(key)) { temp = a[key]; delete a[key]; a[key.charAt(0).toUpperCase() + key.substring(1)] = temp; } } data.items[i] = a; } data.Items = data.items; data.Count = data.count; return ej.WebApiAdaptor.prototype.processResponse.call(this, data, ds, query, xhr, request, changes); } }); var dataManager = ej.DataManager({ url: "api/Orders", adaptor: "WebApiAdaptor" }); dataManager.adaptor = new camelCaseWebApiAdaptor(); $scope.data = dataManager; $scope.tools = ["add", "edit", "delete", "update", "cancel"]; }); </script> |
[Controller] public PageResult<EmployeePhoto> Get(ODataQueryOptions opts) { List<EmployeePhoto> emp = db.EmployeePhotos.ToList(); var count = 0; var results = emp.AsQueryable(); if (opts.InlineCount != null) count = results.Count(); if (opts.Filter != null) { results = opts.Filter.ApplyTo(results, new ODataQuerySettings()).Cast<EmployeePhoto>(); count = results.Count(); } return new PageResult<EmployeePhoto>(opts.ApplyTo(emp.AsQueryable()) as IEnumerable<EmployeePhoto>, null, count); |