I am making a datatable in which I would like to dynamically reorder the columns.
export class myTableComponent {
@Input()
data: any[];
@ContentChildren(Column) myColumn: QueryList<Column>;
}
I have initially a queryList of columns.
on mouseMove I would like to delete one column at a specific index of the queryList. For example, a table with tree columns if i delete on index 2, the table should then display a table with two columns.
How can I modify the queryList? I thought i would just need to splice the querylist but I can't
I have a shadow dom like that
<g-table *ngIf="projects" [data]="projects" (reorder)="reorder($event);">
<g-column draggable>
<template let-row let-index="index"> {{row.cdeProjet}} (<b>{{row.nom}}</b>) {{index}}</template>
</g-column>
<g-column field="nom"></g-column>
<g-column field="title"> <template let-row let-index="index">test</template></g-column>
</g-table>
So I want to dynamically make the 3rd column to be the first.
I know :
- The query list of g-column via contentchildren
- the index of the column I would like to drag.
- the index of the column I would like to replace with.
What is the proper way to do the reorder function? Thanks