How to specify (fixed) width for columns in a data grid ? #1669
-
Hello, I'm using a data grid to display data from a SQLite database (with random generated data for now) and it's working as expected. But the grid changes its size or its columns sizes when I go to "next page" : Some columns, like the first one with a check box does not need to be that large, but the size of other columns seems to vary according to the length of the cells content. How could I specify fixed columns width and fixed grid size ? Edit :
Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hard to say exactly what is happening without seeing the code. You can specify the widths of the columns by setting the GridTemplateColumn parameter on the grid component like this: GridTemplateColumns="0.2fr 1fr 0.2fr 0.2fr 0.2fr 0.2fr" (adjusted to your number of columns of course) |
Beta Was this translation helpful? Give feedback.
-
Thanks for you reply. (I had added the code meanwhile ;)) You have answered my question. GridTemplateColumns="50px 80px 200px 300px" is fine but as soon as I add a "fr" value, in the last column for example, then its width will again vary depending on data (at least I suppose) and then the paginator will change its location. But I think I can go with that :) Thank you very much, |
Beta Was this translation helpful? Give feedback.
Hard to say exactly what is happening without seeing the code. You can specify the widths of the columns by setting the GridTemplateColumn parameter on the grid component like this:
GridTemplateColumns="0.2fr 1fr 0.2fr 0.2fr 0.2fr 0.2fr"
(adjusted to your number of columns of course)