Hi Fabio,
Thanks for using Syncfusion products.
Based on your requirement, we have created a simple grid sample, in which the grid is populated with the data from Web API 2.2 OData Controller and the same can be downloaded from the below location.
Sample Location: http://www.syncfusion.com/downloads/support/directtrac/133090/MvcApplication4-700577905.zip
The below code snippet have been used in the above sample.
@(Html.EJ().Grid<Order>("Grid") .Datasource("/odata/Orders") //Restful service url .AllowSorting() .AllowFiltering() .FilterSettings(filter => filter.FilterType(FilterType.Menu)) .AllowPaging() .Columns(cols => { cols.Field("OrderID").Add(); cols.Field("EmployeeID").Add(); cols.Field("CustomerID").Type("string").Add(); cols.Field("Freight").Format("{0:C}").Add(); cols.Field("ShipName").Type("string").Add(); }) )
|
In the above sample, the filtering, paging and sorting are handled by the controller itself. Please refer the below screenshots for the request and response from the web api.
Paging:
Filtering:
Sorting:
Please let us know if you have any queries.
Regards,
Madhu Sudhanan. P
Hi Madhu Sudhanan P ,
In my case, we are dealing with millions of data, could you recommend an approach or solution for loading these million rows into a paginated grid wherein the data are lazy loaded or loaded on demand. Based on the example, you are getting all the data at once, I am thinking of using Limits for each page. Can you shed light on this? Thanks.
<div class="row">
<div ej-grid id="Grid" e-width="500px" e-datasource="data" e-allowgrouping="true" ------ >
<div e-columns>
-------------------------------
</div>
</div>
</div>
<script>
angular.module("GridCtrl", ["ejangular"])
.controller("bodyCtrl", function ($scope) {
//Provide the datasource to the grid. Here the WebApiAdaptor is used.
$scope.data = ej.DataManager({ url: "/api/Orders", adaptor: "WebApiAdaptor" });
$scope.tools = ["add", "edit", "delete", "update", "cancel", "search"];
});
</script>
---------------------------------------------
public PageResult<OrdersView> Get(ODataQueryOptions opts)
{
List<OrdersView> ord = db.OrdersViews.ToList();
return new PageResult<OrdersView>(opts.ApplyTo(ord.AsQueryable()) as IEnumerable<OrdersView>,null, ord.Count);
} |