BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hello, I have the following goal: to define the width of individual columns using ViewChild/ContentChild. I have tried different approaches, but none of them give me the desired result.
The widths of the individual columns are greater than that specified by the function.
The incoming column Setting Object:
Try 1: Set column width size by column list
Try 2 with getColumnByField
Try 3 with persistence data
I also try to trigger the function by your grid event "load" but it seems, the width size of the columns is not equal to the column size setting from Backend.
When I define a static width value in the Input Property "width" on the grid component -> it works.
However, when I set the width dynamically, it is unfortunately the case that the information from the Column Width Setting Object does not match the information in the view.
Even with whole numbers or pixels I don't get the desired result. In all grids "autoFit" is disabled and is not triggered. I suspect that there is some kind of asynchronous calculation of the width for the rendering of the grid taking place in the background.
Can you please explain this to me and help me? My goal is to define the widths of the individual columns using Content-/ViewChild. I get the information from our backend.
Thanks in advance for the help.
Best regards
Denis Kirchner
Hi Denis,
Query: Set Column width on ViewChild/ContentChild base doesn't work
We are currently working on the sample "Set Column width on ViewChild". Rest assured that we are doing our best to update on or before March 10th,2023. Until then we appreciate your patience and understanding.
Regards,
Dineshnarasimman
Hi Dineshnarasimman,
Thanks for your feedback. I look forward to the update and am excited when I can implement the feature in my Angular project.
Many greetings
Denis Kirchner
Hi Denis,
Thank you for your patience.
Query: Changing the width of individual column using ViewChild or ContentChild
We have analyzed your query about setting width of individual column using ViewChild or ContentChild and we suggest you to take instance of grid instead of individual column and by accessing the column and width property we can change the width of the individual columns. We have attached the code snippet for your reference.
<ejs-grid [dataSource]='data' #grid height='315px'>
@ViewChild('grid') grid:ElementRef|any; ngAfterViewInit(): void { this.grid.getColumnByField("OrderID").width=1000;
}
|
Please let us know if you need further assistance.
Regards,
Dineshnarasimman