This is a migrated thread and some comments may be shown as answers.

Link GridView controls to common widths?

6 Answers 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nicole
Top achievements
Rank 1
Nicole asked on 08 Nov 2011, 09:34 PM
I have a SL control with a TreeView.  Because the data presentation has to be 100% dynamic, the TreeViewItems are created programmatically, then inside each TreeViewItem is a RadGridView with the relevatn data for that TreeViewItem. 

The problem is that the RadGridView controls all end up being different widths.  We can't manually specify column widths since they have to work with whatever the data is.  I've attached a screen shot of the issue.  (Apologies for the ugly redactions.)

Is there a way to somehow link the RadGridViews together (and it has to be in code behind not in the XAML) so they they size themselves based on the widest columns in any of the grids?  Ideally we'd like the grids to all be the same width and the columns to be aligned.

Any thoughts?

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 09 Nov 2011, 07:50 AM
Hello,

 The closest option I can offer you is to specify equal widths for both grids and their columns in pixels. Finding the widest column in any of the grids and equalizing other grids and their columns can lead to unpredictable results - even layout cycles. 

Best wishes,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nicole
Top achievements
Rank 1
answered on 09 Nov 2011, 02:06 PM
Vlad,

Thanks for the reply.  Unfortunately hard coding the column widths is not an option since the data is dynamic.  I have no way of knowing how wide to make them, because the data today will be different than the data tomorrow.

It is possible to set the width of the grid to a percentage?  Even if the columns did not line up exactly, if the grids were the same width that would be helpful.
0
Vlad
Telerik team
answered on 14 Nov 2011, 08:27 AM
Hi,

 You can use star sizing. I suggest you to check this article for more info.

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nicole
Top achievements
Rank 1
answered on 14 Nov 2011, 02:30 PM
I have been unable to get a star-sized value to work in code-behind, since the Width property requires a double value.  I've been trying variations of:
gvSummaries.Width = 0.9*;
gvSummaries.Width = new GridLength(0.9*);
gvSummaries.Width = new GridLength(0.9*, GridUnitType.Star);
gvSummaries.Width = new GridLength(0.9, GridUnitType.Star);

But no luck so far.
0
Vlad
Telerik team
answered on 14 Nov 2011, 02:36 PM
Hi,

 I'm referring to Grid and how size UI elements associated with ColumnDefinition and RowDefinition. 

Best wishes,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nicole
Top achievements
Rank 1
answered on 14 Nov 2011, 03:20 PM
It sounds like it's not possible, which happens sometimes. 

But just to clarify, all UI elements for this application are built dynamically in code-behind.  I cannot specify a size in pixels because I do not know what the data length will be.  Yet, I cannot use a star sized values in code-behind (or at least I haven't found a way yet) since the GridLength and associated methods require a double value, whether it is for the whole grid or for individual columns.  If I could specify manually in pixels that would work great, but that's not an option here.

Tags
GridView
Asked by
Nicole
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Nicole
Top achievements
Rank 1
Share this question
or