$scope.pagingOptions = {
pageSizes: [5,15,20],pageSize: 5,currentPage: 1
};
$scope.filterOptions = {
filterText: '',useExternalFilter: true
};
$scope.totalServerItems = 0;
$scope.getDates = function (pageSize,page,/optional/searchText) {
setTimeout(function () {
if(searchText){
searchText = searchText.toLowerCase();
$http.get('data/hero.php?param='+$stateParams.positionType).success(function (data) {
var data = data.filter(function (item) {
return JSON.stringify(item).indexOf(searchText) != -1;
})
data.forEach(function (item,i) {
item.index = i+1;
});
$scope.totalServerItems = data.length;
$scope.datas=data.slice((page-1)pageSize,pagepageSize);
}).error(function (data) {
alert('请求错误...');
})
}else{
$http.get('data/hero.php?param='+$stateParams.positionType).success(function (data) {
data.forEach(function (item,i) {
item.index = i+1;
});
$scope.totalServerItems = data.length;
$scope.datas = data.slice((page-1)pageSize,pagepageSize);
}).error(function (data) {
alert('请求错误...');
})
}
},100);
};
$scope.getDates($scope.pagingOptions.pageSize,$scope.pagingOptions.currentPage);
$scope.$watch('pagingOptions',function () {
$scope.getDates($scope.pagingOptions.pageSize,$scope.pagingOptions.currentPage);
},true);
$scope.$watch('filterOptions',$scope.pagingOptions.currentPage,$scope.filterOptions.filterText);
},true);
$scope.gridOptions = {
data: 'datas',//表格中显示的数据来源
multiSelect: false,//是否能多选
enableRowSelection: false,//是否能选择行
enableCellSelection: true,//是否能选择单元格
enableCellEdit: false,//是否能修改内容
enablePinning: true,//是否被锁住了
columnDefs: [
{
field: 'index',//这里是数据中的属性名
width: 80,display: '序号',//这里是表格的每一列的名称
pinnable: true,sortable: true //是否能排序
},{
field: 'name',displayName: '姓名',width: 120,sortable: true,pinnable: true
},{
field:'alias',displayName:'别名',width: 60,{
field:'position',displayName: '定位',width: 70,{
field:'equip',displayName: '装备',width: 500,{
field:'id',displayName: '详细攻略',sortable: false,pinnable: true,cellTemplate:'<div class="cellDetail"><a ui-sref="detail({id:row.getProperty(col.field)})" id="{{row.getProperty(col.field)}}">详情
'