vue-ads-table-tree icon indicating copy to clipboard operation
vue-ads-table-tree copied to clipboard

Collapsing/expanding grouped rows got broken in 2.4.2

Open pavelav opened this issue 5 years ago • 6 comments

Unfortunately commit 98e6ff22495a8b5ad8d468fa79025c49f45c592d broke collapsing/expanding the groups. To be precise I'm talking about group rows, not parent-child relationships.

pavelav avatar Dec 10 '19 19:12 pavelav

Hi, @arnedesmedt . Sorry to remind. Is there a chance you'll fix this before Christmas break (it starts Dec 25 for you I assume)? If not any time soon, please let me know - I'll try to find a fix (need this early January).

pavelav avatar Dec 16 '19 21:12 pavelav

Hi, I can't fix this before the first january. I'm moving to another house. But maybe you can try it yourself?

arnedesmedt avatar Dec 17 '19 20:12 arnedesmedt

I'll try to find time for that. Thanks for keeping me informed. Merry upcoming Christmas! :-)

pavelav avatar Dec 17 '19 20:12 pavelav

There is some Vue reactive magic going on. groupBy.js used to contain groupRows data field, which was never read, only assigned in 2 places: groupedRows() and createGroupRow(). Restoring this data field and the latter modification in createGroupRow() makes things work again. What is most surprising is that groupRows() isn't triggered! I would understand if it was, which would trigger flattenedRows() and so on, but that's not the case.

pavelav avatar Dec 23 '19 21:12 pavelav

Hi, @arnedesmedt . I hope you had good holidays :) Is it possible to release a new build with the above workaround (at least as a first step to solving this issue)? Collapse/expand functionality is important for a tree-like component.

pavelav avatar Jan 09 '20 12:01 pavelav

Attaching a diff, so it is clear what I'm talking about in this comment.

diff --git a/src/mixins/groupBy.js b/src/mixins/groupBy.js
index 75acb4e..b6141d6 100644
--- a/src/mixins/groupBy.js
+++ b/src/mixins/groupBy.js
@@ -1,12 +1,19 @@
 // TODO how to handle grouped data for async data
 
 export default {
+    data () {
+        return {
+            groupRows: [],
+        };
+    },
+
     computed: {
         groupedRows () {
             if (this.paginatedRows.length === 0) {
                 return this.paginatedRows;
             }
 
+            // this.groupRows = [];
             return this.groupingRows(this.paginatedRows, 0);
         },
     },
@@ -72,6 +79,7 @@ export default {
             };
 
             this.initRow(groupRow, 0, groupLength, column);
+            this.groupRows.push(groupRow);
 
             return groupRow;
         },

pavelav avatar Jan 09 '20 12:01 pavelav