Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set AG-Grid's height to automatically match the data content height?

I'm trying to get ag-grid's height to match the content.

I have several sets of data which I'm trying to load into different grids, each with the appropriate height for the data.

There is an AutoHeight option but the Angular version doesn't seem to work (I'm assuming this is for a previous version).

Here is my alternative attempt, which doesn't work:

                <ng-container *ngFor="let reportItem of reportData">
                    <br />
                    <ag-grid-angular style="width: 100%; height: {{ 560 + (reportItem.data.length * 40) }}px;"
                                     class="ag-theme-material bold-headers"
                                     [rowData]="reportItem.data"
                                     [columnDefs]="columnDefs">
                    </ag-grid-angular>
                </ng-container>

Does anyone have a better suggestion?

Rather than just linking to the Auto-Grid Height method I described at the top - which I tried and failed with, could you please explain how I should implement it with my code above? (as I accept I may have missed something)

Thanks

like image 287
CompanyDroneFromSector7G Avatar asked Oct 23 '25 05:10

CompanyDroneFromSector7G


1 Answers

according to this link you can use domLayout='autoHeight' as a property to your grid.

it worked for me.

like image 125
Mohammed Nosirat Avatar answered Oct 25 '25 09:10

Mohammed Nosirat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!