Hi Deepika,
Greetings from Syncfusion support.
By analyzing your query, we suspect that you need to autofit the columns for dynamically binding Grid.
Before proceeding with your requirement, we would like to share the behavior of
the autoFitColumns() feature. The
autoFitColumns method resizes all the columns in the Grid to fit the widest cell’s content without wrapping. You can autofit the columns at initial rendering by invoking the
autoFitColumns method in
dataBound event. Refer to the below code example and documentation.
this.grid.autoFitColumns(); // auto fit all the columns in the Grid
|
You can also autofit particular columns in the Grid by passing a string array of column fields in the autoFitColumns method. Refer to the below code example.
this.grid.autoFitColumns(['ShipAddress', 'ShipName']); // auto fit particular column in the Grid
|
You can achieve the same by setting the column API autoFit as true. Refer to the below code example.
<e-column field='OrderID' headerText='Order ID' [autoFit]="true" width=200></e-column>
|
Note: If you want to autofit a particular column by using the autoFitColumns method, then we must know the column’s field or column’s index. Else we cannot autofit the columns.
You can get the columns in the grid by using following methods.
please get back to us if you need further assistance with this.
Regards,
Rajapandiyan S