This question is locked. New answers and comments are not allowed.
How do I get my column widths to auto size, when the column header is resizeable?
e.g. I have a simple grid with a TextBox headers. As the user types into the box, the width increases. If text is removed from the box, the TextBox width decreases but the columns width remains the same.
In this example if you delete the long text, the width will not change.
I had also tried changing the HeaderCellStyle to change its alignment/content alignment to left. This did not achieve the desired result of wanting the Star column to fill up the remaining space.
The overall goal I am trying to achieve is to the standard headers with text boxes to allow for complex (server side) searching; this can not be achieved by filter row, custom filters only control the pop up which does not deliver an optimal user experience, foot search rows is also not optimal.
e.g. I have a simple grid with a TextBox headers. As the user types into the box, the width increases. If text is removed from the box, the TextBox width decreases but the columns width remains the same.
<telerik:RadGridView > <telerik:RadGridView.Columns> <telerik:GridViewColumn > <telerik:GridViewColumn.Header> <TextBox Text="Long texttttttttt" HorizontalAlignment="Left" /> </telerik:GridViewColumn.Header> </telerik:GridViewColumn> <telerik:GridViewColumn Header="Star" Width="*" /> </telerik:RadGridView.Columns></telerik:RadGridView>In this example if you delete the long text, the width will not change.
I had also tried changing the HeaderCellStyle to change its alignment/content alignment to left. This did not achieve the desired result of wanting the Star column to fill up the remaining space.
The overall goal I am trying to achieve is to the standard headers with text boxes to allow for complex (server side) searching; this can not be achieved by filter row, custom filters only control the pop up which does not deliver an optimal user experience, foot search rows is also not optimal.
6 Answers, 1 is accepted
0
Alex
Top achievements
Rank 1
answered on 07 Nov 2014, 04:56 AM
I am using Telerik version:
2014.2.729.1050
2014.2.729.1050
0
Hello Alex,
I am afraid that there is no easy way for achieving this functionality. A possible solution would be to invoke GridView's UpdateLayout method when the TextBox is resized. Unfortunately, this will lead to performance degradation.
Regards,
Yoan
Telerik
I am afraid that there is no easy way for achieving this functionality. A possible solution would be to invoke GridView's UpdateLayout method when the TextBox is resized. Unfortunately, this will lead to performance degradation.
Regards,
Yoan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Alex
Top achievements
Rank 1
answered on 12 Nov 2014, 03:56 AM
Hi Yoan,
I tried doing as you suggested, however, calling UpdateLayout did not result in the columns shrinking back down (It does not result in any visual change)
I've also discovered that this scenario can be very easily produced by using the out of the box RadGridView, and by typing into the FilterRow and then removing what you typed
I tried doing as you suggested, however, calling UpdateLayout did not result in the columns shrinking back down (It does not result in any visual change)
I've also discovered that this scenario can be very easily produced by using the out of the box RadGridView, and by typing into the FilterRow and then removing what you typed
0
Hello Alex,
You can try another approach - you can calculate the width of the TextBox in its SizeChanged event. Then you can set the Width of the column to be the calculated width. I have attached a sample project which demonstrates this approach.
Regards,
Yoan
Telerik
You can try another approach - you can calculate the width of the TextBox in its SizeChanged event. Then you can set the Width of the column to be the calculated width. I have attached a sample project which demonstrates this approach.
Regards,
Yoan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Alex
Top achievements
Rank 1
answered on 13 Nov 2014, 10:10 PM
I had tried this earlier but it did not achieve the desired result of GridViewLength.Auto ~like behaviour.
I had set the GridViewColumn's width to the GridViewHeaderCell.DesiredSize.Width if it was less than the RenderSize.Width then I would revert it back to the previous width (Auto). This would make the column width shrink to the header size, but not to the cells size.
I had set the GridViewColumn's width to the GridViewHeaderCell.DesiredSize.Width if it was less than the RenderSize.Width then I would revert it back to the previous width (Auto). This would make the column width shrink to the header size, but not to the cells size.
0
Hi Alex,
I have already answered your other forum thread.
Regards,
Yoan
Telerik
I have already answered your other forum thread.
Regards,
Yoan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.