I'm storing the column widths of my ngx-datatable inside a database. I get these values using an AJAX call.
How can I set these values for the datatable?
What I've tried:
<ngx-datatable-column>
element@ViewChild(DatatableComponent) table: DatatableComponent;
and setting this.table.bodyComponent.columns[0].width = 500;
this.table.recalculate();
, but nothing seems to work.
EDIT
I'm using datatable-column
with header-template
and cell-template
.
If you use the solution of Hoang Duc Nguyen, you can also store the width in the columns:
columns = [
{ name: 'Name', prop: 'name', width: 250},
{ name: 'Gender', prop: 'gender'},
{ name: 'Company', prop: 'company', sortable: false }
];