Skip to content
This repository was archived by the owner on Dec 4, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ jspm_packages
npm-debug.log
dist
.idea
.DS_Store
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# angular-data-table
# angular-data-table

[![Join the chat at https://gitter.im/Swimlane/angular-data-table](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/swimlane/angular-data-table?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![npm-version](https://img.shields.io/npm/v/angular-data-table.svg)
Expand All @@ -8,7 +8,7 @@

`angular-data-table` is a AngularJS directive for presenting large and complex data. It has all the features you would expect from any other table but in a light package with _no external depedencies_. The table was designed to be extremely flexible and light; it doesn't make any assumptions about your data or how you: filter, sort or page it.

It was engineered from its conception to handle thousands of rows without sacrificing performance. It was built for modern browsers using _ES6, CSS3 and HTML5_ and **only supports [Evergreen Browsers](http://eisenbergeffect.bluespire.com/evergreen-browsers/) and Angular >= 1.4.x and < 1.6.0**.
It was engineered from its conception to handle thousands of rows without sacrificing performance. It was built for modern browsers using _ES6, CSS3 and HTML5_ and **only supports [Evergreen Browsers](http://eisenbergeffect.bluespire.com/evergreen-browsers/) and Angular >= 1.4.x and < 1.7.0**.

Sadly, this project is **not Angular2 upgrade compatible**. Fortunately, we have authored [angular2-data-table](https://github.com/swimlane/angular2-data-table) which is the successor to this project. **We are going to slowly be transitioning this project maintenance mode**. We will continue to provide feedback to the community and accept PRs but we won't be doing any major new development.

Expand Down Expand Up @@ -55,7 +55,7 @@ You've got 5 different options to include this in your build depending on your s
- `./release/dataTable.min.js` - A minified standalone file that was compiled with Babel (UMD)
- `./release/dataTable.cjs.js` - A standalone file that was compiled with Babel (CommonJS)
- `./release/dataTable.es6.js` - Raw ES6 Version.

All distributions include babel helpers, so they do not have to be included separately.

There is also the CSS too:
Expand Down
216 changes: 138 additions & 78 deletions release/dataTable.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,46 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var PagerController = function () {
PagerController.$inject = ["$scope"];
function PagerController($scope) {
var _this = this;

_classCallCheck(this, PagerController);

$scope.$watch('pager.count', function (newVal) {
_this.calcTotalPages(_this.size, _this.count);
_this.getPages(_this.page || 1);
});

$scope.$watch('pager.size', function (newVal) {
_this.calcTotalPages(_this.size, _this.count);
_this.getPages(_this.page || 1);
});

$scope.$watch('pager.page', function (newVal) {
if (newVal !== 0 && newVal <= _this.totalPages) {
_this.getPages(newVal);
}
Object.assign(this, {
$scope: $scope
});

this.getPages(this.page || 1);
if (angular.version.major === 1 && angular.version.minor < 5) {
this.init();
}
}

_createClass(PagerController, [{
key: "$onInit",
value: function $onInit() {
this.init();
}
}, {
key: "init",
value: function init() {
var _this = this;

this.$scope.$watch('pager.count', function (newVal) {
_this.calcTotalPages(_this.size, _this.count);
_this.getPages(_this.page || 1);
});

this.$scope.$watch('pager.size', function (newVal) {
_this.calcTotalPages(_this.size, _this.count);
_this.getPages(_this.page || 1);
});

this.$scope.$watch('pager.page', function (newVal) {
if (newVal !== 0 && newVal <= _this.totalPages) {
_this.getPages(newVal);
}
});

this.getPages(this.page || 1);
}
}, {
key: "calcTotalPages",
value: function calcTotalPages(size, count) {
var count = size < 1 ? 1 : Math.ceil(count / size);
Expand Down Expand Up @@ -175,17 +191,34 @@ function PagerDirective() {
var FooterController = function () {
FooterController.$inject = ["$scope"];
function FooterController($scope) {
var _this2 = this;

_classCallCheck(this, FooterController);

this.page = this.paging.offset + 1;
$scope.$watch('footer.paging.offset', function (newVal) {
_this2.offsetChanged(newVal);
Object.assign(this, {
$scope: $scope
});

if (angular.version.major === 1 && angular.version.minor < 5) {
this.init();
}
}

_createClass(FooterController, [{
key: "$onInit",
value: function $onInit() {
this.init();
}
}, {
key: "init",
value: function init() {
var _this2 = this;

this.page = this.paging.offset + 1;

this.$scope.$watch('footer.paging.offset', function (newVal) {
_this2.offsetChanged(newVal);
});
}
}, {
key: "offsetChanged",
value: function offsetChanged(newVal) {
this.page = newVal + 1;
Expand Down Expand Up @@ -819,49 +852,65 @@ function ScrollerDirective($timeout, $rootScope) {
var BodyController = function () {
BodyController.$inject = ["$scope", "$timeout"];
function BodyController($scope, $timeout) {
var _this3 = this;

_classCallCheck(this, BodyController);

this.$scope = $scope;
this.tempRows = [];

this.treeColumn = this.options.columns.find(function (c) {
return c.isTreeColumn;
Object.assign(this, {
$scope: $scope,
$timeout: $timeout
});

this.groupColumn = this.options.columns.find(function (c) {
return c.group;
});
if (angular.version.major === 1 && angular.version.minor < 5) {
this.init();
}
}

$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this));
_createClass(BodyController, [{
key: "$onInit",
value: function $onInit() {
this.init();
}
}, {
key: "init",
value: function init() {
var _this3 = this;

if (this.options.scrollbarV || !this.options.scrollbarV && this.options.paging.externalPaging) {
var sized = false;
$scope.$watch('body.options.paging.size', function (newVal, oldVal) {
if (!sized || newVal > oldVal) {
_this3.getRows();
sized = true;
}
});
this.tempRows = [];

$scope.$watch('body.options.paging.count', function (count) {
_this3.count = count;
_this3.updatePage();
this.treeColumn = this.options.columns.find(function (c) {
return c.isTreeColumn;
});

$scope.$watch('body.options.paging.offset', function (newVal) {
if (_this3.options.paging.size) {
_this3.onPage({
offset: newVal,
size: _this3.options.paging.size
});
}
this.groupColumn = this.options.columns.find(function (c) {
return c.group;
});
}
}

_createClass(BodyController, [{
this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this));

if (this.options.scrollbarV || !this.options.scrollbarV && this.options.paging.externalPaging) {
var sized = false;
this.$scope.$watch('body.options.paging.size', function (newVal, oldVal) {
if (!sized || newVal > oldVal) {
_this3.getRows();
sized = true;
}
});

this.$scope.$watch('body.options.paging.count', function (count) {
_this3.count = count;
_this3.updatePage();
});

this.$scope.$watch('body.options.paging.offset', function (newVal) {
if (_this3.options.paging.size) {
_this3.onPage({
offset: newVal,
size: _this3.options.paging.size
});
}
});
}
}
}, {
key: "rowsUpdated",
value: function rowsUpdated(newVal, oldVal) {
if (newVal) {
Expand Down Expand Up @@ -957,7 +1006,7 @@ var BodyController = function () {
}, {
key: "calculateDepth",
value: function calculateDepth(row) {
var depth = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;

var parentProp = this.treeColumn ? this.treeColumn.relationProp : this.groupColumn.prop;
var prop = this.treeColumn.prop;
Expand Down Expand Up @@ -2057,41 +2106,52 @@ var TableDefaults = {
};

var DataTableController = function () {
DataTableController.$inject = ["$scope", "$filter", "$log", "$transclude"];
function DataTableController($scope, $filter, $log, $transclude) {
var _this6 = this;

DataTableController.$inject = ["$scope", "$filter"];
function DataTableController($scope, $filter) {
_classCallCheck(this, DataTableController);

Object.assign(this, {
$scope: $scope,
$filter: $filter,
$log: $log
$filter: $filter
});

this.defaults();
if (angular.version.major === 1 && angular.version.minor < 5) {
this.init();
}
}

this.options.$outer = $scope.$parent;
_createClass(DataTableController, [{
key: "$onInit",
value: function $onInit() {
this.init();
}
}, {
key: "init",
value: function init() {
var _this6 = this;

$scope.$watch('dt.options.columns', function (newVal, oldVal) {
_this6.transposeColumnDefaults();
this.defaults();

if (newVal.length !== oldVal.length) {
_this6.adjustColumns();
}
this.options.$outer = this.$scope.$parent;

_this6.calculateColumns();
}, true);
this.$scope.$watch('dt.options.columns', function (newVal, oldVal) {
_this6.transposeColumnDefaults();

var watch = $scope.$watch('dt.rows', function (newVal) {
if (newVal) {
watch();
_this6.onSorted();
}
});
}
if (newVal.length !== oldVal.length) {
_this6.adjustColumns();
}

_createClass(DataTableController, [{
_this6.calculateColumns();
}, true);

var watch = this.$scope.$watch('dt.rows', function (newVal) {
if (newVal) {
watch();
_this6.onSorted();
}
});
}
}, {
key: "defaults",
value: function defaults() {
var _this7 = this;
Expand Down
Loading