|
330 | 330 | * @methodOf ui.grid.treeBase.api:PublicApi
|
331 | 331 | * @description expand the immediate children of the specified row
|
332 | 332 | * @param {gridRow} row the row you wish to expand
|
| 333 | + * @param {boolean} recursive true if you wish to expand the row's ancients |
333 | 334 | */
|
334 |
| - expandRow: function (row) { |
335 |
| - service.expandRow(grid, row); |
| 335 | + expandRow: function (row, recursive) { |
| 336 | + service.expandRow(grid, row, recursive); |
336 | 337 | },
|
337 | 338 |
|
338 | 339 | /**
|
|
804 | 805 | if (row.treeNode.state === uiGridTreeBaseConstants.EXPANDED){
|
805 | 806 | service.collapseRow(grid, row);
|
806 | 807 | } else {
|
807 |
| - service.expandRow(grid, row); |
| 808 | + service.expandRow(grid, row, false); |
808 | 809 | }
|
809 | 810 |
|
810 | 811 | grid.queueGridRefresh();
|
|
819 | 820 | *
|
820 | 821 | * @param {Grid} grid grid object
|
821 | 822 | * @param {GridRow} row the row we want to expand
|
| 823 | + * @param {boolean} recursive true if you wish to expand the row's ancients |
822 | 824 | */
|
823 |
| - expandRow: function ( grid, row ){ |
824 |
| - if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){ |
825 |
| - return; |
826 |
| - } |
| 825 | + expandRow: function ( grid, row, recursive ){ |
| 826 | + if ( recursive ){ |
| 827 | + var parents = []; |
| 828 | + while ( row && typeof(row.treeLevel) !== 'undefined' && row.treeLevel !== null && row.treeLevel >= 0 && row.treeNode.state !== uiGridTreeBaseConstants.EXPANDED ){ |
| 829 | + parents.push(row); |
| 830 | + row = row.treeNode.parentRow; |
| 831 | + } |
827 | 832 |
|
828 |
| - if ( row.treeNode.state !== uiGridTreeBaseConstants.EXPANDED ){ |
829 |
| - row.treeNode.state = uiGridTreeBaseConstants.EXPANDED; |
830 |
| - grid.api.treeBase.raise.rowExpanded(row); |
831 |
| - grid.treeBase.expandAll = service.allExpanded(grid.treeBase.tree); |
832 |
| - grid.queueGridRefresh(); |
| 833 | + if ( parents.length > 0 ){ |
| 834 | + row = parents.pop(); |
| 835 | + while ( row ){ |
| 836 | + row.treeNode.state = uiGridTreeBaseConstants.EXPANDED; |
| 837 | + grid.api.treeBase.raise.rowExpanded(row); |
| 838 | + row = parents.pop(); |
| 839 | + } |
| 840 | + |
| 841 | + grid.treeBase.expandAll = service.allExpanded(grid.treeBase.tree); |
| 842 | + grid.queueGridRefresh(); |
| 843 | + } |
| 844 | + } else { |
| 845 | + if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){ |
| 846 | + return; |
| 847 | + } |
| 848 | + |
| 849 | + if ( row.treeNode.state !== uiGridTreeBaseConstants.EXPANDED ){ |
| 850 | + row.treeNode.state = uiGridTreeBaseConstants.EXPANDED; |
| 851 | + grid.api.treeBase.raise.rowExpanded(row); |
| 852 | + grid.treeBase.expandAll = service.allExpanded(grid.treeBase.tree); |
| 853 | + grid.queueGridRefresh(); |
| 854 | + } |
833 | 855 | }
|
834 | 856 | },
|
835 | 857 |
|
|
0 commit comments