Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to Keep Rows Expanded in Grouped Tables #704

Merged
merged 9 commits into from
May 6, 2020

Conversation

robgaston1
Copy link
Contributor

@robgaston1 robgaston1 commented May 6, 2020

Description

We are attempting to implement a grouped table using the collapsable option. Our use case for the table is adding and removing things similar to a shopping cart. However, since the computed originalRows clones the rows anytime a change is made, the vgtIsExpanded property on a headerRow gets lost anytime you alter the rows.

Proposed Solution

This PR adds a new option as a prop, maintainExpanded. The prop allows you to enable this feature, as well as pass in a rowKey, so a value that is a unique identifier for your specific data. There is a data property expandedRowKeys that tracks all of the rows that are expanded, which is then checked when the originalRows are recomputed to maintain the expanded value.

One additional change made is that the rowStyleClass prop that we pass into vue-good-table does not get applied to the header-rows. In our case we need to apply the same row styles to the header rows as the child rows.

@TheJaredWilcurt
Copy link
Collaborator

This solution makes sense and the code looks good (have not ran locally yet), but it would be good to document this as well. Can you add documentation in with this PR

enabled: true,
collapsable: true
}"
:maintain-expanded="{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maintainExpanded only pertains to the Group options, and should probably be combined with them.

groupOptions: {
  enabled: true,
  collapsable: true,
  maintainExpanded: true,
  rowKey: 'id'
}

@TheJaredWilcurt TheJaredWilcurt merged commit 063a148 into xaksis:master May 6, 2020
@xaksis
Copy link
Owner

xaksis commented May 9, 2020

@robgaston1 thank you for bringing this up. This should be the default option for collapsable rows.
I'll be releasing a fix that turns this option on by default. There's a unique identifier for header rows assigned internally in the table, so I don't think we need the rowKey option.
I'll be releasing a modified version of this PR shortly.

@robgaston1
Copy link
Contributor Author

@xaksis I'm glad an internal id could be used. I couldn't figure out how to maintain that unique identifier inside the header row, so that's awesome. Thanks for releasing this so quickly!

p0psicles pushed a commit to p0psicles/vue-good-table that referenced this pull request Jun 24, 2020
* add row style class to header row
* add logic to maintain expanded rows
* add documentation
p0psicles pushed a commit to p0psicles/vue-good-table that referenced this pull request Jun 24, 2020
* add row style class to header row
* add logic to maintain expanded rows
* add documentation
xaksis pushed a commit that referenced this pull request Jul 22, 2020
* Add feature to enable checking all checkboxes of a grouped table's children.
The checkbox is available in span/non-span mode in the vgt-header-row.

* Option to Keep Rows Expanded in Grouped Tables (#704)

* add row style class to header row
* add logic to maintain expanded rows
* add documentation

* Check for the selectAllByGoup using the same 'typeof' as the others

* Move @click for vgtExpand to span's with the triangle and the header label.
* This, because if it's on the TR, it will also expand when the checkbox is clicked.

* Update docs

* Remove groupOptions.
Maybe used it at some point, But not anymore.

* Remove doc (rebase thing?)

* Newline

Co-authored-by: Rob Gaston <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants