前端分页JS文件中的代码如下:(function (angular) {
`<br />
var app = angular.module(‘app’);
<br />
<br />
function CardTypeListModalCtrl($scope, $uibModalInstance, ajaxService) {
<br />
<br />
$scope.items = [];
<br />
$scope.total_result = 0;
<br />
$scope.filter = {};
<br />
//$scope.filter = config.filter;
<br />
<br />
var pager = {
<br />
page_no: 1,
<br />
page_size: 10,
<br />
sortName: ‘CREATETIME’,
<br />
isDesc: true,
<br />
}
<br />
$scope.post_data = {
<br />
pager: pager,
<br />
paramData: {
<br />
//CARDNAME: $scope.filter.CARDNAME,
<br />
filter:$scope.filter
<br />
},
<br />
};
<br />
$scope.querysearch = function () {
<br />
if ($scope.loading) return;
<br />
$scope.loading = true;
<br />
//$scope.pageChanged();
<br />
$scope.post_data.paramData = JSON.stringify($scope.filter);
<br />
<br />
ajaxService.AjaxGet(‘card.CardTypeSelModal.GetCardTypeList’, $scope.post_data, function (rsp) {
<br />
<br />
$scope.items = rsp.array;
<br />
$scope.post_data.pager.page_no = 1;
<br />
$scope.radioItem = {
<br />
selectItem: null,
<br />
};
<br />
$scope.loading = false;
<br />
});
<br />
}
<br />
<br />
$scope.pageChanged = function () {
<br />
//if ($scope.loading) return;
<br />
//$scope.loading = true;
<br />
//**如果是服务器端分页,则把调用后台接口部分,放到此方法中,前端每次点页码,就会请求后台接口
**``<br />
<br />
};
<br />
<br />
$scope.orderByChange = function (sortName) {
<br />
if (sortName == $scope.post_data.pager.sortName) {
<br />
$scope.post_data.pager.isDesc = !$scope.post_data.pager.isDesc;
<br />
}
<br />
else {
<br />
$scope.post_data.pager.sortName = sortName;
<br />
$scope.post_data.pager.isDesc = false;
<br />
}
<br />
$scope.querysearch();
<br />
}
<br />
<br />
$scope.filterChange = function (name, value) {
<br />
$scope.post_data[name] = value;
<br />
$scope.querysearch();
<br />
}
<br />
<br />
$scope.radioSelect = function (item) {
<br />
$scope.radioItem.selectItem = item;
<br />
}
<br />
<br />
$scope.ok = function () {
<br />
$uibModalInstance.close($scope.radioItem.selectItem);
<br />
}
<br />
<br />
$scope.cancel = function () {
<br />
$uibModalInstance.dismiss(‘cancel’);
<br />
}
<br />
}
<br />
<br />
app.filter(“typefmt”, function () {
<br />
return function (type) {
<br />
var arrStr = [“年卡”, “多次卡”, “储值卡”, “大客户卡”];
<br />
return arrStr[type-1];
<br />
}
<br />
})
<br />
<br />
app.factory(‘CardTypeListModalService’, [‘$uibModal’, ‘ajaxService’, function ($uibModal, ajaxService) {
<br />
var service = {};
<br />
<br />
service.showModal = function () {
<br />
var modalInstance = $uibModal.open({
<br />
//animation: false,
<br />
templateUrl: ‘/Card/views/CardTypeModal.html?t=12’,
<br />
controller: CardTypeListModalCtrl,
<br />
size: ‘llg’,
<br />
});
<br />
<br />
return modalInstance;
<br />
};
<br />
<br />
return service;
<br />
}]);
<br />
<br />
})(window.angular)`
html中的代码:
C#中代码:
public TopResponse GetResponse(NameValueCollection parameters)
{
var filter = parameters.ValidateJson
//服务器端分页,则获取客户端请求的分页信息
//var pager = parameters.ValidateJson
var pager = new Hsort.Common.Data.PagerParams();
pager.pageSize = 200;
var list = CardTypeHelper.GetCardTypeList(filter, pager);
return new ArrayResponse(list, pager.totalResult);
}
}