E
E
EA-EKB2021-05-31 16:44:59
Angular
EA-EKB, 2021-05-31 16:44:59

Is it possible to set the width of Ngx-Datatable columns depending on their content in that column?

Hello.
Can you please tell me whether it is realistic to set the width of the columns of the ngx-datatable component depending on their content and am I digging in the right direction? Google does not find anything similar, only a strict setting of the width, without reference to the content. I'm just starting to work with Angular, so maybe I'm digging in the wrong place at all.

For example, there is a table of 10 rows, the content of the second column is of different widths, let's say 100px, 50px, 140px, 175px (maximum width), etc. How to make it so (and is it really possible to do so) so that the column has a width of 175px (in this case)?

Nothing comes to my mind except how to get elements with content using template variables (so-so solution because it will be non-universal, and there are several tables, and I wouldn’t want to litter in templates with unnecessary variables), getting the maximum width value and entering it into the width property of the desired column. Update the property with a hardcoded value - the table is rendered with columns of the specified width. It remains only to get the width of the content, but I can not figure out how to do this.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question