Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
large JSON data table example added.
- Loading branch information
Showing
3 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
resources/public/angular-js-study/jsonFiles/largeLoad.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[{"name": "Moroni", "allowance": 505050505050505050, "paid": true}, | ||
{"name": "Tiancum", "allowance": 53, "paid": false}, | ||
{"name": "Jacob", "allowance": 27, "paid": false}, | ||
{"name": "Nephi", "allowance": 29, "paid": false}, | ||
{"name": "Enos", "allowance": 34, "paid": false}, | ||
{"name": "Ether", "allowance": 42, "paid": false}, | ||
{"name": "Alma", "allowance": 43, "paid": true}, | ||
{"name": "Jared", "allowance": 21, "paid": true}, | ||
{"name": "Moroni", "allowance": 50, "paid": true}, | ||
{"name": "Tiancum", "allowance": 53, "paid": false}, | ||
{"name": "Jacob", "allowance": 27, "paid": false}, | ||
{"name": "Nephi", "allowance": 29, "paid": false}, | ||
{"name": "Enos", "allowance": 34, "paid": false}, | ||
{"name": "Ether", "allowance": 42, "paid": false}, | ||
{"name": "Alma", "allowance": 43, "paid": true}, | ||
{"name": "Jared", "allowance": 21, "paid": true}, | ||
{"name": "Moroni", "allowance": 50, "paid": true}, | ||
{"name": "Tiancum", "allowance": 53, "paid": false}, | ||
{"name": "Jacob", "allowance": 27, "paid": false}, | ||
{"name": "Nephi", "allowance": 29, "paid": false}, | ||
{"name": "Enos", "allowance": 34, "paid": false}, | ||
{"name": "Ether", "allowance": 42, "paid": false}, | ||
{"name": "Alma", "allowance": 43, "paid": true}, | ||
{"name": "Jared", "allowance": 21, "paid": true}, | ||
{"name": "Moroni", "allowance": 50, "paid": true}, | ||
{"name": "Tiancum", "allowance": 53, "paid": false}, | ||
{"name": "Jacob", "allowance": 27, "paid": false}, | ||
{"name": "Nephi", "allowance": 29, "paid": false}, | ||
{"name": "Enos", "allowance": 34, "paid": false}, | ||
{"name": "Ether", "allowance": 42, "paid": false}, | ||
{"name": "Alma", "allowance": 43, "paid": true}, | ||
{"name": "Jared", "allowance": 21, "paid": true}, | ||
{"name": "Moroni", "allowance": 50, "paid": true}, | ||
{"name": "Tiancum", "allowance": 53, "paid": false}, | ||
{"name": "Tiancum", "allowance": 53, "paid": false}, | ||
{"name": "Jacob", "allowance": 27, "paid": false}, | ||
{"name": "Nephi", "allowance": 29, "paid": false}, | ||
{"name": "Enos", "allowance": 34, "paid": false}, | ||
{"name": "Ether", "allowance": 42, "paid": false}, | ||
{"name": "Alma", "allowance": 43, "paid": true}, | ||
{"name": "Jared", "allowance": 21, "paid": true}, | ||
{"name": "Moroni", "allowance": 50, "paid": true}, | ||
{"name": "Tiancum", "allowance": 53, "paid": false}, | ||
{"name": "Jacob", "allowance": 27, "paid": false}, | ||
{"name": "Nephi", "allowance": 29, "paid": false}, | ||
{"name": "Enos", "allowance": 34, "paid": false}, | ||
{"name": "Ether", "allowance": 42, "paid": false}, | ||
{"name": "Alma", "allowance": 43, "paid": true}, | ||
{"name": "Jared", "allowance": 21, "paid": true}, | ||
{"name": "Tiancum", "allowance": 53, "paid": false}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!doctype html> | ||
<html ng-app="myapp"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="Content-Language" content="ja"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> | ||
<meta name="HandheldFriendly" content="True"> | ||
<meta name="MobileOptimized" content="320"> | ||
<!-- jquery --> | ||
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | ||
<!-- angular.js --> | ||
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.js"></script> | ||
<!-- angular bootstrap ui with templates --> | ||
<script type="text/javascript" src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.9.0.js"></script> | ||
<!-- Latest compiled and minified CSS --> | ||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"> | ||
<!-- ng-grid.js & .css --> | ||
<script type="text/javascript" src="ng-grid-2.0.7.min.js"></script> | ||
<link rel="stylesheet" href="ng-grid.min.css"> | ||
<style> | ||
.gridStyle { | ||
border: 1px solid rgb(212,212,212); | ||
width: 600px; | ||
height: 300px; | ||
} | ||
</style> | ||
<!-- example --> | ||
<script type="text/javascript" src="sample-07.js"></script> | ||
</head> | ||
<body> | ||
<div ng-controller="GridDemoCtrl"> | ||
<div class="gridStyle" ng-grid="gridOptions"></div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
var app = angular.module('myapp', ['ui.bootstrap', 'ngGrid']); | ||
app.controller('GridDemoCtrl', function($scope, $http) { | ||
$scope.filterOptions = { | ||
filterText: "", | ||
useExternalFilter: true | ||
}; | ||
$scope.totalServerItems = 0; | ||
$scope.pagingOptions = { | ||
pageSizes: [25, 50, 100], | ||
pageSize: 25, | ||
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('jsonFiles/largeLoad.json').success(function (largeLoad) { | ||
data = largeLoad.filter(function(item) { | ||
return JSON.stringify(item).toLowerCase().indexOf(ft) != -1; | ||
}); | ||
$scope.setPagingData(data,page,pageSize); | ||
}); | ||
} else { | ||
$http.get('jsonFiles/largeLoad.json').success(function (largeLoad) { | ||
$scope.setPagingData(largeLoad,page,pageSize); | ||
}); | ||
} | ||
}, 100); | ||
}; | ||
|
||
$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage); | ||
|
||
$scope.$watch('pagingOptions', function (newVal, oldVal) { | ||
if (newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) { | ||
$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); | ||
|
||
$scope.gridOptions = { | ||
data: 'myData', | ||
enablePaging: true, | ||
showFooter: true, | ||
totalServerItems: 'totalServerItems', | ||
pagingOptions: $scope.pagingOptions, | ||
filterOptions: $scope.filterOptions | ||
}; | ||
}); |