[CdkTable] consolidate data index in RowContext
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 91
Description
#### Bug, feature request, or proposal: proposal
#### What is the expected behavior?
Property pointing at the location of the row in the data source should be the same
for `CdkCellOutletMultiRowContext` and `CdkCellOutletRowContext`
#### What is the current behavior?
The property pointing at the location of the row in the data source is `index` in single-row template mode and `dataIndex` in multi-row tempalte mode.
#### What is the use-case or motivation for changing an existing behavior?
When working with the context, to figure out which property to use one will have to have
access to the table to query `multiTemplateDataRows` or check both properties which is >= 0.
The use case is for more complex tables, where a row model is needed and the context can be used as such.
This get's really annoying when working with templates... you need to explicitly request `index` and `dataIndex` in the template and query for the one in use... because 0 is a valid value doing `||` is not good as you might end up with `undefined`
I know that `RowContext` is public thus `index` and `dataIndex` must stay but it can be deprecated in the long run...
The code in the method `_updateRowIndexContext()` can become:
```ts
context.index = context.dataIndex = this._renderRows[renderIndex].dataIndex;
if (this.multiTemplateDataRows) {
context.renderIndex = renderIndex;
}
```
Instead of
```ts
if (this.multiTemplateDataRows) {
context.dataIndex = this._renderRows[renderIndex].dataIndex;
context.renderIndex = renderIndex;
} else {
context.index = this._renderRows[renderIndex].dataIndex;
}
```
And in future version deprecate one of the properties.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par lire `_updateRowIndexContext()` et la modification proposée dans l’issue. Vérifiez comment il met à jour `index`, `dataIndex` et `renderIndex` pour les modes de template à une ligne et à plusieurs lignes. C’est terminé lorsque les deux types de contexte de ligne exposent le même index de source de données, tandis que le mode à plusieurs lignes définit toujours l’index de rendu.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- frontend
- Type d'issue
- Fonctionnalité
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 48/100