Brief context:
I have a page with n number of rows using for:each={rows} for:item="row"
. Each row has its own checkbox.
There is a filtering feature that (by rerendering the with a getter) hides/shows these rows from the DOM based on the entered criteria.
The issue is that the state of the checkbox is not "remembered" after being filtered out.
Example: Default for all checkboxes is unchecked > I check one checkbox ON > enter a criteria to filter out this checkbox from the page > remove the filter > my checkbox shows again and returns to default state, OFF.
Each row has the appropriate boolean via row.isChecked
for whether or not it should be checked stored in my JS. Is there something analogous to the following?
HTML:
<lightning-input type="toggle" checked={row.isChecked}></lightning-input>
Because, unfortunately in HTML, the presence/absence of the 'checked' attribute controls the state.
I haven't found a way to effectively use the setAttribute() and removeAttribute() methods.
EDIT: I can NOT use querySelectors for this.