Hi,
I'm using ejs-grid into an Angular component. The component uses asyncPipe and get the data from a service, that returns an Observable with data and columns for the grid.
I want to show the data and columns on the grid and also add two custom columns to grid, but when the data arrives the custom columns isn't show.
This is an example of the template:<ng-container *ngIf="data$ | async as tableData">
<ejs-grid #table
[dataSource]="tableData.data"
[columns]="tableData.columns">
<e-columns>
<e-column type='checkbox' width='50' [showInColumnChooser]='false'></e-column>
<e-column *ngFor="let column of tableData.columns"
[field]='column.field' [headerText]='column.headerText'>
</e-column>
<e-column headerText='Acciones' width='150' textAlign='Right'>
<ng-template #template let-data>
<button class="table-action" >Editar </button>
<button class="table-action" > Eliminar </button>
</ng-template>
</e-column>
</e-columns>
</ejs-grid>
</ng-container>
This is an example of the component:
...
@Component({ ... })
export class MyComponent implements OnInit {
@ViewChild('table') public table: GridComponent;
data$: Observable<TableData>
constructor(private tableService: TableService) { }
ngOnInit(): void {
this.data$ = this.tableService.getData();
}
}
...
The method getData() returns an Observable with data with this shape, for example:export interface TableData{
data: any[];
columns: any[];
}
I have seen on this link: documentation, that the Observable should be an object with properties result and count, that it is not my case at the moment. If I pass the data with this properties, how I pass the column info dinamically? in another property of the component?
My objective is get data and column definition from a service, pass this data to the ejs-grid, and also define custom columns to add to the grid on the template.
How can I get my objective with ejs-grid?
Thanks