|
100 | 100 | /**
|
101 | 101 | * @ngdoc object
|
102 | 102 | * @name ui.grid.expandable.api:GridRow
|
103 |
| - * |
| 103 | + * |
104 | 104 | * @description Additional properties added to GridRow when using the expandable module
|
105 | 105 | */
|
106 | 106 | /**
|
|
186 | 186 | */
|
187 | 187 | toggleAllRows: function() {
|
188 | 188 | service.toggleAllRows(grid);
|
| 189 | + }, |
| 190 | + /** |
| 191 | + * @ngdoc function |
| 192 | + * @name expandRow |
| 193 | + * @methodOf ui.grid.expandable.api:PublicApi |
| 194 | + * @description Expand the data row |
| 195 | + * @param {object} rowEntity gridOptions.data[] array instance |
| 196 | + */ |
| 197 | + expandRow: function (rowEntity) { |
| 198 | + var row = grid.getRow(rowEntity); |
| 199 | + if (row !== null && !row.isExpanded) { |
| 200 | + service.toggleRowExpansion(grid, row); |
| 201 | + } |
| 202 | + }, |
| 203 | + /** |
| 204 | + * @ngdoc function |
| 205 | + * @name collapseRow |
| 206 | + * @methodOf ui.grid.expandable.api:PublicApi |
| 207 | + * @description Collapse the data row |
| 208 | + * @param {object} rowEntity gridOptions.data[] array instance |
| 209 | + */ |
| 210 | + collapseRow: function (rowEntity) { |
| 211 | + var row = grid.getRow(rowEntity); |
| 212 | + if (row !== null && row.isExpanded) { |
| 213 | + service.toggleRowExpansion(grid, row); |
| 214 | + } |
| 215 | + }, |
| 216 | + /** |
| 217 | + * @ngdoc function |
| 218 | + * @name getExpandedRows |
| 219 | + * @methodOf ui.grid.expandable.api:PublicApi |
| 220 | + * @description returns all expandedRow's entity references |
| 221 | + */ |
| 222 | + getExpandedRows: function () { |
| 223 | + return service.getExpandedRows(grid).map(function (gridRow) { |
| 224 | + return gridRow.entity; |
| 225 | + }); |
189 | 226 | }
|
190 | 227 | }
|
191 | 228 | }
|
|
215 | 252 | if (angular.isUndefined(row.expandedRowHeight)){
|
216 | 253 | row.expandedRowHeight = grid.options.expandableRowHeight;
|
217 | 254 | }
|
218 |
| - |
| 255 | + |
219 | 256 | if (row.isExpanded) {
|
220 | 257 | row.height = row.grid.options.rowHeight + row.expandedRowHeight;
|
221 | 258 | }
|
|
253 | 290 | else {
|
254 | 291 | service.expandAllRows(grid);
|
255 | 292 | }
|
| 293 | + }, |
| 294 | + |
| 295 | + getExpandedRows: function (grid) { |
| 296 | + return grid.rows.filter(function (row) { |
| 297 | + return row.isExpanded; |
| 298 | + }); |
256 | 299 | }
|
257 | 300 | };
|
258 | 301 | return service;
|
|
0 commit comments