This repository has been archived by the owner on Jan 7, 2022. It is now read-only.
forked from swimlane/angular-data-table
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature add: Demo with all options toggleable (#27)
* - importing angular everywhere but base * moved directives to default export * added all options, some small bug fixes * initial commit
- Loading branch information
1 parent
717193d
commit 38fbd31
Showing
29 changed files
with
233 additions
and
54 deletions.
There are no files selected for viewing
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,191 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset=" utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<meta name="apple-mobile-web-app-capable" content="yes" /> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> | ||
<meta name="viewport" content="width = device-width, minimal-ui, initial-scale = 1, user-scalable = no" /> | ||
<meta name="apple-mobile-web-app-title" content="Datagrid"> | ||
<title>Datagrid - All Options</title> | ||
<base href="/"> | ||
<style> | ||
*, *:after, *:before { | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
} | ||
|
||
body{ | ||
font-family: 'RobotoDraft', 'Roboto', 'Helvetica Neue, Helvetica, Arial', sans-serif; | ||
font-style: normal; | ||
font-weight: 300; | ||
font-size: 1.4rem; | ||
line-height: 2rem; | ||
letter-spacing: 0.01rem; | ||
color: #212121; | ||
background-color: #f5f5f5; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-rendering: optimizeLegibility; | ||
} | ||
|
||
.dt{ | ||
width:75%; | ||
margin:50px auto; | ||
} | ||
|
||
</style> | ||
<link href="../dist/dataTable.css" media="all" rel="stylesheet" /> | ||
<link href="../dist/themes/material.css" media="all" rel="stylesheet" /> | ||
<link href="http://fontastic.s3.amazonaws.com/Jnf54BZCm7mSjGCxNRbfp3/icons.css" rel="stylesheet"> | ||
</head> | ||
<body ng-app="app" ng-controller="HomeController"> | ||
<button type="button" ng-click="clearData()">Clear Data</button> | ||
<button type="button" ng-click="loadData()">Load Data</button> | ||
|
||
<button type="button" ng-click="groupCountry()">Group on Country</button> | ||
<button type="button" ng-click="groupYear()">Group on Year</button> | ||
<button type="button" ng-click="groupingOff()">Grouping off</button> | ||
|
||
<label><input type="checkbox" ng-change="addRemovePaging()" ng-model="hasPaging" />Has Paging</label> | ||
<label><input type="checkbox" ng-change="addRemoveScrollbarV()" ng-model="hasScrollbarV" />Has ScrollbarV</label> | ||
<label><input type="checkbox" ng-model="showTable" />Show Table</label> | ||
|
||
<div ng-if="showTable"> | ||
<dtable options="options" rows="data" class="material" on-row-dbl-click="onRowDblClick(row)"></dtable> | ||
</div> | ||
|
||
<script src="../jspm_packages/system.js"></script> | ||
<script src="../config.js"></script> | ||
|
||
<script> | ||
|
||
System.import('dataTable').then(function(dt){ | ||
var module = angular.module('app', [ dt.default.name ]); | ||
|
||
module.controller('HomeController', function($scope, $http){ | ||
window.scope = $scope; | ||
$scope.hasPaging = false; | ||
$scope.hasScrollbarV = false; | ||
$scope.showTable = true; | ||
$scope.data = []; | ||
|
||
$scope.options = { | ||
rowHeight: 50, | ||
headerHeight: 50, | ||
footerHeight: false, | ||
scrollbarV: $scope.hasScrollbarV, // Note: this loses reference to scope variable when passed to directive | ||
selectable: false, | ||
columns: [ | ||
{ name: 'Athlete', prop: 'athlete', width: 300 }, | ||
{ name: 'Country', prop: 'country' }, | ||
{ name: 'Year', prop: 'year' }, | ||
{ name: 'Sport', prop: 'sport' } | ||
] | ||
}; | ||
|
||
$scope.onRowDblClick = function(row) { | ||
console.log('Row Double Clicked', row); | ||
} | ||
|
||
/** Loading/Clearing data section **/ | ||
$scope.loadData = function() { | ||
$scope.data = undefined; | ||
|
||
$http.get('/demos/data/olympics.json').success(function(data) { | ||
$scope.data = data; | ||
|
||
if ($scope.hasPaging) { | ||
angular.extend($scope.options, { | ||
paging: { | ||
count: data.length | ||
} | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
$scope.clearData = function() { | ||
if ($scope.data) { | ||
$scope.data.splice(0, $scope.data.length); | ||
|
||
if ($scope.options.paging.count) { | ||
angular.extend($scope.options.paging, { | ||
count: 0 | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
/** Grouping section **/ | ||
|
||
$scope.groupCountry = function() { | ||
_clearGroupColumns(); | ||
|
||
var col = $scope.options.columns.find(function(c) { | ||
return c.prop === 'country'; | ||
}); | ||
|
||
col.group = !col.group; | ||
}; | ||
|
||
$scope.groupYear = function() { | ||
_clearGroupColumns(); | ||
|
||
var col = $scope.options.columns.find(function(c) { | ||
return c.prop === 'year'; | ||
}); | ||
|
||
col.group = !col.group; | ||
}; | ||
|
||
$scope.groupingOff = function() { | ||
_clearGroupColumns(); | ||
}; | ||
|
||
function _clearGroupColumns() { | ||
$scope.options.columns.map(function(column) { | ||
if (column.group) { | ||
delete column.group; | ||
} | ||
}); | ||
}; | ||
|
||
/** Paging section **/ | ||
$scope.addRemovePaging = function() { | ||
if ($scope.hasPaging) { | ||
angular.extend($scope.options, { | ||
footerHeight: 50, | ||
paging: { | ||
size: 10, | ||
count: ($scope.data) ? $scope.data.length : 0 | ||
} | ||
}); | ||
} else { | ||
angular.extend($scope.options, { | ||
footerHeight: undefined, | ||
paging: {} | ||
}); | ||
} | ||
}; | ||
|
||
/** Scrollbar section **/ | ||
$scope.addRemoveScrollbarV = function() { | ||
if ($scope.hasScrollbarV) { | ||
angular.extend($scope.options, { | ||
scrollbarV: true | ||
}); | ||
} else { | ||
angular.extend($scope.options, { | ||
scrollbarV: false | ||
}); | ||
} | ||
} | ||
|
||
}); | ||
}); | ||
</script> | ||
|
||
</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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.