Posted: 31 May 2019 9:47 EDT Last activity: 31 May 2019 14:32 EDT
How to iterate through nested clones on a web page
I have a web page with a dynamic table that has the days within a specified range as labels for the rows. Then the table is expandable along the columns as well as more years are added. I have clones for each of the dates and then for each column, however when I try to iterate through the rows and columns, I note that I am going to each row but only staying on the first row of the table when I edit values within the column clones. I have attached an automation wherein I attempt to copy data from one column to its respective part in the same row, and iterate through those columns.
I believe your screenshot is incorrect, but I don't believe I need it to assist. The tricky part with iterating through nested clones, is that the GetClones method does not accept a key. This method will only return the collection of clones for a key of None (which is really the first instance). If you need to access nested clones, you'll need to construct your own table.
The basic concept is;
Create a LookupTable with two fields; Key and ParentKey.
Use the Created event for the child clones to add records to this LookupTable.
Use the Destroyed event for the child clones to remove records from this LookupTable.
If there is an event that occurs where you know all the clones are gone, you can clear the LookupTable as a safe way to keep it small.
When you need to iterate through the child clones, you can call GetKeys on the LookupTable and pass that into a ListLoop. You can call GetRecord from the LookupTable to get the ParentKey and compare this to the parent key you are looking for. The Item coming out of the list loop is the key for each of the children.
You can also filter the DataTable from the LookupTable (accessed by calling GetTable) using C# if you're more comfortable doing that. Ultimately, the ParentKey is what is filtered on and the matching child keys can be used to access the clones.