Need help with concept. Creating a custom item that displays data from my database. Using a repeat pattern, it works great. The report is grouped and therefore each row in the report contains a different level of data that is displayed after you collapse into a row. So now I want to โupdateโ the report data to reflect changes in sorting or grouping. The report is based on an โindexingโ array that points to actual data. I sort / group data in an index array and use this array as an array to repeat the pattern.
<div id="rptbody"> <template repeat="{{group in groups}}"> <pmg-group groupid={{group.id}} groupval={{group.groupval}} groupobj={{group.groupobj}}></pmg-group> </template> </div>
So, in this example, an array of groups is a list of keys for my data. In this example, the array of groups is ordered correctly, so [0] contains the first index of the data array, and [length-1] contains the last. I have a sort that changes the index value in groups, but does not add or remove elements from the array of groups.
So my question after my resort is how to get the template to re-view the list of groups. I found that I can set groups = [] and then reload groups (groups.push ({idx}) from my main index, and it will update the template, however it seems wasteful to me.
Is there a way to initiate a template update or re-scan of an array of groups and reorganization of the DOM based on value changes? Do I think this?
Thoughts?
Dan
source share