Update datatable.component.md documentation (#8525)

This commit is contained in:
Eugenio Romano
2023-05-18 10:19:46 +02:00
committed by GitHub
parent c431d0c6f5
commit 7e1ff20069

View File

@@ -18,6 +18,7 @@ See it live: [DataTable Quickstart](https://embed.plnkr.co/80qr4YFBeHjLMdAV0F6l/
- [Basic usage](#basic-usage)
- [Setting the rows and column schema](#setting-the-rows-and-column-schema)
- [Transclusions](#transclusions)
- [Row Update](#row-update)
- [Class members](#class-members)
- [Properties](#properties)
- [Events](#events)
@@ -247,6 +248,59 @@ export class DataTableDemo {
</adf-datatable>
```
### Row Update
Starting with v6.0.0, you need to provide a [`DataTableService`](../../lib/core/src/lib/datatable/services/datatable.service.ts) to update a row of your table.
The model to update the DataTable require the `id` of the row that is being changed, and the new data Object of the row:
```typescript
interface DataRowUpdateModel {
obj: any;
id: string;
}
```
For example, if your table use entry nodes you can pass:
```typescript
this.dataTableService.rowUpdate.next({
id: node.id,
obj: {
entry: node
}
});
```
As good practice, it is suggested to provide a [`DataTableService`](../../lib/core/src/lib/datatable/services/datatable.service.ts) at the component level:
```typescript
@Component({
selector: 'app-files-component',
templateUrl: './files.component.html',
styleUrls: ['./files.component.scss'],
encapsulation: ViewEncapsulation.None,
providers: [
DataTableService
]
})
export class FilesComponent implements OnInit {
constructor(private dataTableService: DataTableService,
private nodeService: NodesApiService) {
}
ngOnInit() {
this.nodeService.nodeUpdated.subscribe((node) => {
this.dataTableService.rowUpdate.next({
id: node.id,
obj: {
entry: node
}
});
});
}
}
```
### [Transclusions](../../user-guide/transclusion.md)
You can add [Data column component](data-column.component.md) instances to define columns for thetable as described in the usage examples and the [Customizing columns](#customizing-columns) section.