feat(table): enable multiple data rows #11116
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Originally at #10964
Introduces a new table input
multiTemplateDataRows
which allows the table to have multiple data rows per data object.Old paradigm
Each data object passed to the table is rendered as a data row. Since the mapping is 1:1, the data array itself can be used with the
IterableDiffer
to determine which rows need to change.New paradigm
Each data object passed to the table may be rendered by one or more rows. The
IterableDiffer
cannot use the data array itself anymore since it will not correctly understand add/remove/move operations in the rows.Instead, the
IterableDiffer
will be diffed with aDataRow
object that represents a pair containing a data object and row template. When the data changes, the list ofDataRow
objects will be constructed and diffed to get the list of changes.Caveats for discussion
index
value that represented both the row index and data object index (they were the same. Now, thatindex
value represents the index of the data. To get the row index, there is an additional context property calledrowIndex
.Should it be swapped such that
index
is the row index and the data index can be stored indataIndex
?trackBy
function receives an index value. Previously the index matched both the data and row. Now, its explicitly the data index.Should
trackBy
receive the row index?