-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat(table): update select all on addition or removal of rows #632
base: main
Are you sure you want to change the base?
Changes from 4 commits
4bbd149
0314818
c8ec0bc
435a4c6
ae8a329
e884a18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -438,11 +438,26 @@ <h2>Data table with sortable columns</h2> | |
</gux-table> | ||
|
||
<h2>Object table with rows selection</h2> | ||
<ul> | ||
<li> | ||
Use the <strong>setChecked</strong> method on | ||
<strong>gux-all-row-select</strong> to programatically manage the selected | ||
state. | ||
</li> | ||
<li> | ||
Use the <strong>setIndeterminate</strong> method to set the | ||
indeterminate/unknown state on <strong>gux-all-row-select</strong>. Remember | ||
to set it to false when the checkbox is checked or unchecked as it overrides | ||
these states. | ||
</li> | ||
</ul> | ||
<gux-button id="selectAll">Select all</gux-button> | ||
<gux-button id="deselecAll">Deselect all</gux-button> | ||
<gux-table object-table selectable-rows> | ||
<table slot="data"> | ||
<thead> | ||
<tr data-row-id="head"> | ||
<th><gux-all-row-select></gux-all-row-select></th> | ||
<th><gux-all-row-select id="allRowSelect"></gux-all-row-select></th> | ||
<th data-column-name="first-name">First name</th> | ||
<th data-column-name="last-name">Last name</th> | ||
<th data-column-name="age" data-cell-numeric>Age</th> | ||
|
@@ -970,7 +985,21 @@ <h2>Data table with fixed columns</h2> | |
} | ||
|
||
|
||
}) | ||
}); | ||
|
||
const selectAll = document.getElementById('selectAll'); | ||
const deselectAll = document.getElementById('deselecAll'); | ||
const allRowSelect = document.getElementById('allRowSelect'); | ||
|
||
selectAll.addEventListener('click', () => { | ||
allRowSelect.setIndeterminate(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to house this within the
or
as I am not sure is it valid to call a method with a Watch decorator internally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I did initially look at that but decided to keep the setting of checked & indeterminate states separate to keep it inline with the native checkbox as there were a few issues. Apparently 'indeterminate' is a presentational state, just visual, while the value of a checkbox is either checked or unchecked. I thought it best to stick with this to avoid any unforeseen issues down the road by diverging from the native checkbox. |
||
allRowSelect.setChecked(true); | ||
}); | ||
|
||
deselectAll.addEventListener('click', () => { | ||
allRowSelect.setIndeterminate(false); | ||
allRowSelect.setChecked(false); | ||
}); | ||
})()" | ||
> | ||
.not-used { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be easier to just query select the
gux-all-row-select
element instead of adding anid
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would select all the
gux-all-row-select
's on the page, I just want to select that particular one as it relates to one particular table.