$scope.getOrders = function () {
return OrderService.GetList($scope.filter).then(function (response) {
$scope.data = response.Items;
count = response.Count; //get record count
}, function (response) {
//Errors here..
});
};
$scope.onComplete = function (args) {
if ((args.requestType == "refresh" || args.requestType == "paging")) {
var pager = this.getPager().ejPager("instance");
if (args.requestType == "paging") $scope.filter = { top: 9, skip: args.startIndex, currentpage: args.currentPage };
if(this.initialRender || args.requestType == "paging") $scope.getOrders();
setTimeout(function () {
pager.model.totalRecordsCount = count;//set the pager total records count
pager.model.currentPage = $scope.filter.currentpage;
//set additional settings for pager
pager.refreshPager();
},0)
}
} |
public PageResult<Orders> Get(ODataQueryOptions opts)
{
if (order.Count == 0)
BindDataSource();
IEnumerable<Orders> dataSource = order;
var emp = order.AsQueryable();
var count = emp.Count();
if (opts.OrderBy != null)
emp = opts.OrderBy.ApplyTo(emp); //perform sort
if (opts.Filter != null)
emp = opts.Filter.ApplyTo(emp, new ODataQuerySettings()).Cast<Orders>(); //perform filter
if (opts.InlineCount != null)
count = emp.ToList().Count;
if (opts.Skip != null)
emp = opts.Skip.ApplyTo(emp, new ODataQuerySettings()); //perform skip
if (opts.Top != null)
emp = opts.Top.ApplyTo(emp, new ODataQuerySettings()); //perform take
return new PageResult<Orders>(emp, null, count);
} |
div>
…………………………………
<div ej-grid id="Grid" e-width="500px" e-datasource="data" e-create="gridCreate" e-columns="col" e-allowpaging="true" e-pagesettings="pageset">
………………………………
</div>
<script>
var operator = "";
angular.module("GridCtrl", ["ejangular"])
.controller("bodyCtrl", function ($scope) {
$scope.data = ej.DataManager({
url: "/api/Orders",
adaptor: new ej.WebApiAdaptor()
});
$scope.pageset = { pageSize: 3 };
})
</script>
|