@{
ViewBag.Title = "ViewRegion";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{
Regions
}
@section scripts{
//Module
//Module.js
var RegionApp = angular.module('regionApp',
['ngAnimate', // support for CSS-based animations
'ngTouch', //for touch-enabled devices
'ui.grid', //data grid for AngularJS
'ui.grid.pagination', //data grid Pagination
'ui.grid.resizeColumns', //data grid Resize column
'ui.grid.moveColumns', //data grid Move column
'ui.grid.pinning', //data grid Pin column Left/Right
'ui.grid.selection', //data grid Select Rows
'ui.grid.autoResize', //data grid Enabled auto column Size
]);
//Controller
app.controller('RegionCtrl', function ($scope, $http) {
$scope.filterOptions = {
filterText: "",
useExternalFilter: true
};
$scope.totalServerItems = 0;
$scope.pagingOptions = {
pageSizes: [1, 2, 3, 4, 5],
pageSize: 5,
currentPage: 1
};
$scope.setPagingData = function (data, page, pageSize) {
var pagedData = data.slice((page - 1) * pageSize, page * pageSize);
$scope.myData = pagedData;
$scope.totalServerItems = data.length;
if (!$scope.$$phase) {
$scope.$apply();
}
};
$scope.getPagedDataAsync = function (pageSize, page, searchText) {
setTimeout(function () {
var data;
if (searchText) {
var ft = searchText.toLowerCase();
$http.get("@Url.Action("GetRegionList", "Region")").success(function (largeLoad) {
data = largeLoad.filter(function (item) {
return JSON.stringify(item).toLowerCase().indexOf(ft) != -1;
});
$scope.setPagingData(data, page, pageSize);
});
} else {
$http.get("@Url.Action("GetRegionList", "Region")").success(function (largeLoad) {
$scope.setPagingData(largeLoad, page, pageSize);
});
}
}, 100);
};
// Watch for page and page size changes, re-fill the grid using the new options when they change
$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);
$scope.$watch(
function () {
return {
currentPage: $scope.pagingOptions.currentPage,
pageSize: $scope.pagingOptions.pageSize
};
},
function (newVal, oldVal) {
// Reset to page 1 when the page size changes
if (newVal.pageSize !== oldVal.pageSize) {
$scope.pagingOptions.currentPage = 1;
}
$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText);
},
true);
$scope.$watch('filterOptions', function (newVal, oldVal) {
if (newVal !== oldVal) {
$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText);
}
}, true);
var colDefs = [
{ field: 'vcRgnCode', name: 'Code', headerCellTemplate: 'filterHeaderTemplate.html' },
{ field: 'vcRgnName', name: 'Name' },
{ field: 'vcRgnDesc', name: 'Description' }
]
$scope.gridOptions = {
data: 'myData',
enablePaging: true,
showFooter: true,
totalServerItems: 'totalServerItems',
pagingOptions: $scope.pagingOptions,
filterOptions: $scope.filterOptions,
//enableRowSelection: false,
};
});
}
Ajaykumar SinghPosted Oct 19, 2016, 9:01 AM
Bikesh SrivastavaPosted Oct 17, 2016, 9:07 AM