From 6ad004aecfbce8795b28dc80862df406377fdc8f Mon Sep 17 00:00:00 2001 From: Jon Shaffer Date: Tue, 16 Aug 2016 14:29:17 -0400 Subject: [PATCH] changes to determine --- src/components/DataTableController.js | 4 ++-- src/components/DataTableDirective.js | 3 ++- src/components/header/HeaderCellController.js | 7 ++++--- src/components/header/HeaderCellDirective.js | 9 ++++++--- src/components/header/HeaderController.js | 1 + src/components/header/HeaderDirective.js | 4 ++++ 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/DataTableController.js b/src/components/DataTableController.js index d0a0e64..27ef58d 100644 --- a/src/components/DataTableController.js +++ b/src/components/DataTableController.js @@ -243,8 +243,8 @@ export class DataTableController { * @return {Boolean} if all selected */ isAllRowsSelected(){ - if(this.rows) return false; - return this.selected.length === this.rows.length; + console.log(this.selected.length, ((this.rows) ? this.rows.length : null), (!this.rows) ? false : this.selected.length === this.rows.length); + return (!this.rows) ? false : this.selected.length === this.rows.length; } /** diff --git a/src/components/DataTableDirective.js b/src/components/DataTableDirective.js index 521c303..dc291f9 100644 --- a/src/components/DataTableDirective.js +++ b/src/components/DataTableDirective.js @@ -38,7 +38,8 @@ export function DataTableDirective($window, $timeout, $parse){ column-widths="dt.columnWidths" ng-if="dt.options.headerHeight" on-resize="dt.onResized(column, width)" - selected="dt.isAllRowsSelected()" + is-all-rows-selected="dt.isAllRowsSelected()" + selected-rows="dt.selected" on-sort="dt.onSorted()"> diff --git a/src/components/header/HeaderController.js b/src/components/header/HeaderController.js index 36ea34b..015356f 100644 --- a/src/components/header/HeaderController.js +++ b/src/components/header/HeaderController.js @@ -76,6 +76,7 @@ export class HeaderController { * @param {scope} */ onCheckboxChanged(){ + console.log('HeaderController.onCheckboxChanged', this); this.onCheckboxChange(); } diff --git a/src/components/header/HeaderDirective.js b/src/components/header/HeaderDirective.js index c7ea0ab..d79d3bd 100644 --- a/src/components/header/HeaderDirective.js +++ b/src/components/header/HeaderDirective.js @@ -11,6 +11,8 @@ export function HeaderDirective($timeout){ options: '=', columns: '=', columnWidths: '=', + isAllRowsSelected: '=', + selectedRows: '=?', onSort: '&', onResize: '&', onCheckboxChange: '&' @@ -32,6 +34,8 @@ export function HeaderDirective($timeout){ sort-type="header.options.sortType" on-resize="header.onResized(column, width)" selected="header.isSelected()" + is-all-rows-selected="header.isAllRowsSelected" + selected-rows="header.selectedRows" column="column">