Skip to content

Commit

Permalink
feat(expandable): Add 'expandRow', 'collapseRow' and 'getExpandedRows'
Browse files Browse the repository at this point in the history
I need these features for a project for a project I am currently working on.

add collapseRow method
  • Loading branch information
Rafael Borochov committed Feb 2, 2016
1 parent a70e390 commit 005ca6a
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/features/expandable/js/expandable.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
/**
* @ngdoc object
* @name ui.grid.expandable.api:GridRow
*
*
* @description Additional properties added to GridRow when using the expandable module
*/
/**
Expand Down Expand Up @@ -186,6 +186,43 @@
*/
toggleAllRows: function() {
service.toggleAllRows(grid);
},
/**
* @ngdoc function
* @name expandRow
* @methodOf ui.grid.expandable.api:PublicApi
* @description Expand the data row
* @param {object} rowEntity gridOptions.data[] array instance
*/
expandRow: function (rowEntity) {
var row = grid.getRow(rowEntity);
if (row !== null && !row.isExpanded) {
service.toggleRowExpansion(grid, row);
}
},
/**
* @ngdoc function
* @name collapseRow
* @methodOf ui.grid.expandable.api:PublicApi
* @description Collapse the data row
* @param {object} rowEntity gridOptions.data[] array instance
*/
collapseRow: function (rowEntity) {
var row = grid.getRow(rowEntity);
if (row !== null && row.isExpanded) {
service.toggleRowExpansion(grid, row);
}
},
/**
* @ngdoc function
* @name getExpandedRows
* @methodOf ui.grid.expandable.api:PublicApi
* @description returns all expandedRow's entity references
*/
getExpandedRows: function () {
return service.getExpandedRows(grid).map(function (gridRow) {
return gridRow.entity;
});
}
}
}
Expand Down Expand Up @@ -215,7 +252,7 @@
if (angular.isUndefined(row.expandedRowHeight)){
row.expandedRowHeight = grid.options.expandableRowHeight;
}

if (row.isExpanded) {
row.height = row.grid.options.rowHeight + row.expandedRowHeight;
}
Expand Down Expand Up @@ -253,6 +290,12 @@
else {
service.expandAllRows(grid);
}
},

getExpandedRows: function (grid) {
return grid.rows.filter(function (row) {
return row.isExpanded;
});
}
};
return service;
Expand Down

0 comments on commit 005ca6a

Please sign in to comment.