ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Grid auto-fit to contents
Title:
B
I
{code}
?
Can you make the grid auto-fit to its contents? I have some grids with relatively narrow numbers that are too stretched when they go 100% wide, but I'd also like to avoid specifying a table width. It would be best if the grid columns behaved like a default html table and auto-fit to the contents rendered inside. Thanks.
Save Changes
Cancel
David Austin
asked at 05 Feb 2016
give width to your columns and add an empty column at the end without Width .Columns(..., new Column{ Resizable = false }) )
at 05 Feb 2016
Omu
Sorry, that is creating a big empty column, and the table is still 100% wide. Any other suggestion?
at 05 Feb 2016
David Austin
the grid by default will take 100%, you can set its with using .Width(int), this will give it a fixed width, you can also specify the default column width using .ColumnWidth; as for grid resizing to the width of the columns, you could only do that using custom js ( $grid.on('aweload', func); ), for example having that empty column you could get its width, and calculate the width in px (currentWidth - emptyColWidth) to set for the grid main div;
at 05 Feb 2016
Omu
I'll try that if I have some time. Thanks for the fast answer regardless!
at 05 Feb 2016
David Austin
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK