Width of child grid

4 posts, 0 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 21 Apr 2015 Link to this post

    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

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 22 Apr 2015 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Glenn
    Glenn avatar
    2 posts
    Member since:
    Jun 2016

    Posted 10 Aug in reply to Dimitrina Link to this post

    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?

  5. Stefan X1
    Admin
    Stefan X1 avatar
    518 posts

    Posted 12 Aug Link to this post

    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.
Back to Top