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

Width of child grid

5 Answers 111 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 21 Apr 2015, 01:14 PM

Hi,

 

I tried a hierarchical grid like this:

 

<telerik:GridView Grid.Row="2" RowIndicatorVisibility="Collapsed" CanUserSelect="False" IsReadOnly="True" ItemsSource="{Binding ProductConfigurations}" ShowInsertRow="False" CanUserInsertRows="False" CanUserReorderColumns="False" ShowGroupPanel="False" CanUserEditRows="False" CanUserDeleteRows="False" AutoGenerateColumns="False">
    <telerik:GridView.HierarchyChildTemplate>
        <DataTemplate>
            <telerik:GridView Grid.Row="1" Margin="24,0,0,0" RowIndicatorVisibility="Collapsed" CanUserSelect="False" IsReadOnly="True" ItemsSource="{Binding ProductConfigurationVariants}" ShowInsertRow="False" CanUserInsertRows="False" CanUserReorderColumns="False" ShowGroupPanel="False" CanUserEditRows="False" CanUserDeleteRows="False" AutoGenerateColumns="False">
                <telerik:GridView.Columns>
                    <telerik:GridViewDataColumn Header="VariantNr" DataMemberBinding="{Binding VariantNr}" Width="90" IsSortable="True" IsFilterable="False" />
                    <telerik:GridViewDataColumn Header="SalesOrderCode" DataMemberBinding="{Binding SalesOrderCode}" Width="120" IsFilterable="True" />
                    <telerik:GridViewDataColumn Header="ProductionOrderCode" DataMemberBinding="{Binding ProductionOrderCode}" Width="*" IsSortable="True" IsFilterable="False"/>
                    <telerik:GridViewDataColumn Header="NavTransferID" DataMemberBinding="{Binding NavTransferID}" Width="100" IsFilterable="False" IsSortable="False" />
                    <telerik:GridViewDataColumn Header="NavTransferStatus" DataMemberBinding="{Binding NavTransferStatus}" Width="120" IsFilterable="False" IsSortable="False" />
                    <telerik:GridViewDataColumn Header="NavTransferActionCode" DataMemberBinding="{Binding NavTransferActionCode}" Width="140" IsFilterable="False" IsSortable="False" />
                </telerik:GridView.Columns>
            </telerik:GridView>
        </DataTemplate>
    </telerik:GridView.HierarchyChildTemplate>
    <telerik:GridView.ChildTableDefinitions>
        <telerik:GridViewTableDefinition>
            <telerik:GridViewTableDefinition.Relation>
                <telerik:PropertyRelation ParentPropertyName="ProductConfiguration"/>
            </telerik:GridViewTableDefinition.Relation>                            
        </telerik:GridViewTableDefinition>
    </telerik:GridView.ChildTableDefinitions>
    <telerik:GridView.Columns>
        <telerik:GridViewDataColumn Header="ItemNr" DataMemberBinding="{Binding ItemNr}" Width="80" IsSortable="True" IsFilterable="False" />
        <telerik:GridViewDataColumn Header="ItemStatus" DataMemberBinding="{Binding ItemStatus}" Width="90" IsSortable="True" IsFilterable="False" />
        <telerik:GridViewDataColumn Header="PLMItemNumber" DataMemberBinding="{Binding PLMItemNumber}" Width="120" IsFilterable="True" />
        <telerik:GridViewDataColumn Header="HWProductionOrderCode" DataMemberBinding="{Binding HWProductionOrderCode}" Width="*" IsSortable="True" IsFilterable="False"/>
        <telerik:GridViewDataColumn Header="NavTransferID" DataMemberBinding="{Binding NavTransferID}" Width="100" IsFilterable="False" IsSortable="False" />
        <telerik:GridViewDataColumn Header="NavTransferStatus" DataMemberBinding="{Binding NavTransferStatus}" Width="120" IsFilterable="False" IsSortable="False" />
        <telerik:GridViewDataColumn Header="NavTransferActionCode" DataMemberBinding="{Binding NavTransferActionCode}" Width="140" IsFilterable="False" IsSortable="False" />
        <telerik:GridViewDataColumn Header="NumVar" DataMemberBinding="{Binding ProductConfigurationVariants.Count}" Width="60" IsSortable="False" IsFilterable="False"/>
    </telerik:GridView.Columns>
</telerik:GridView>

This works so far - but the child grid is extremely wide.
I can remove this behavior when I have no column with Width="*" in the child.
With the Width="*" this columns fills more than the width of the parent grid.

All other columns are fix - but this one can contain longer text - so removing the "*" is not an option.
The desired outcome is a child Grid that fills the parent - with one column "AutoExpanding".

 

As a workaroundI tried to bind the Width of the child grid to another element on the UserControl - Width="{Binding ActualWidth, ElementName=xRect}".

But this results in a binding error.

Manfred

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 22 Apr 2015, 08:41 AM
Hi Manfred,

I am afraid when RadGridView is placed in a hierarchy or row details, then its size will be measured with infinity. Consequently you will need to specify a fixed Width for the details RadGridView so that when you set Width="*" for any column, it will fill all the available space.

Regards,
Dimitrina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Glenn
Top achievements
Rank 1
answered on 10 Aug 2016, 06:15 AM

Hi Dimitrina,

I have the same problem. If I set the width of any of the columns to "*" in a HeirarchyChildTemplate, the grid expands wayyyyy off the page.

Has there been a fix or workaround to this problem?

0
Stefan
Telerik team
answered on 12 Aug 2016, 11:41 AM
Hi Glenn,

As stated by my colleague, this would be the expected behavior. There is no way for the parent grid to be aware what control is defined within its hierarchy or row details. Thus, whatever element you define in it, it is being measured with infinity. As already suggested, you can set a fixed Width for the child grid and only the available size will be filled.

Best Regards,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Pete
Top achievements
Rank 1
answered on 19 Dec 2018, 10:14 PM

I manged to resolve this issue by setting the child grid width to that of the parent.

Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}}}"

0
Stefan
Telerik team
answered on 24 Dec 2018, 01:14 PM
Hello Pete,

Thank you for sharing your solution with the community.

All the best,
Stefan
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Dimitrina
Telerik team
Glenn
Top achievements
Rank 1
Stefan
Telerik team
Pete
Top achievements
Rank 1
Share this question
or