With the grid defined as:
<jqxGrid #myGrid
[width]="800"
[source]="dataAdapter"
[columns]="columns"
[autoheight]="true"
[pageable]="true"
[virtualmode]="true"
[rendergridrows]="rendergridrows">
</jqxGrid>
and
export class AppComponent {
@ViewChild('myGrid', { static: false }) myGrid: jqxGridComponent;
source: any =
{
datatype: 'json',
datafields: [],
url: 'http://localhost/getrows',
cache: false,
root: 'Rows',
beforeprocessing: (data: any) => {
this.source.totalrecords = data.TotalRows;
}
};
dataAdapter: any = new jqx.dataAdapter(this.source);
columns: any[] =
[
{ text: 'First Name', datafield: 'first_name', width: 250 },
{ text: 'Last Name', datafield: 'last_name', width: 150 }
];
rendergridrows = (params: any): any => {
return params.data;
}
}
I would like to resize the columns with
this.myGrid.autoresizecolumns();
Where should I insert this command in order to resize the columns after the grid downloads the data from 'http://localhost/getrows'
url. I tried to use this autoresizecolumns
command into the rendergridrows
method. But the resizing there happens too soon since the Binding is not yet Completed in the rendergridrows
method.