Hierarchy Expand

8 posts, 0 answers
  1. Orit
    Orit avatar
    97 posts
    Member since:
    Jun 2009

    Posted 11 Aug 2009 Link to this post

    How can I remove the expand icon where there is no data in the child
    this is my code
    <telerik:RadGridView  Margin="15,5,15,5" Name="gvRequest" Height="auto" Width="Auto" 
                                     xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"   
                                     telerik:StyleManager.Theme="Simple" AutoGenerateColumns="False"   
                                     IsFilteringAllowed="False" FlowDirection="RightToLeft" ShowGroupPanel="False">  
                        <telerik:RadGridView.Columns> 
                            <telerik:GridViewDataColumn UniqueName="ActivityName" Header="שם&#13;תת פעילות" Width="Auto" /> 
                            <telerik:GridViewDataColumn UniqueName="RequestID" Header="מספר&#13;דרישה" Width="Auto" /> 
                            <telerik:GridViewDataColumn UniqueName="RequestName" Header="שם&#13;דרישה" Width="Auto" /> 
                            <telerik:GridViewDataColumn UniqueName="RequestTotal" Header="סכום הדרישה &#13;(K ש''ח)" Width="Auto" /> 
                            <telerik:GridViewDataColumn UniqueName="RequestType" Header="סוג&#13;הדרישה" Width="Auto" />                         
                            <telerik:GridViewDataColumn UniqueName="Supplier" Header="ספק" Width="Auto" /> 
                            <telerik:GridViewDataColumn UniqueName="RequestBalance" Header="יתרה בדרישה &#13;(K ש''ח)" Width="Auto" /> 
                        </telerik:RadGridView.Columns> 
                            <telerik:RadGridView.HierarchyChildTemplate> 
                                <DataTemplate> 
                                    <StackPanel DataContext="{x:Null}">  
                                        <telerik:RadGridView CanUserReorderColumns="False" Name="gvOrder" 
                                                 CanUserFreezeColumns="False" ShowGroupPanel="False" ColumnsWidthMode="Auto" AutoGenerateColumns="False" ItemsSource="{Binding}" 
                                                 Loaded="OnChildGridLoaded" FlowDirection="RightToLeft" IsFilteringAllowed="False" ShowColumnHeaders="True" ColumnBackground="AliceBlue" HorizontalContentAlignment="Right" ClipToBounds="True">  
                                            <telerik:RadGridView.Columns> 
                                                <telerik:GridViewDataColumn UniqueName="OrderID" Header="מספר&#13;הזמנה" Width="Auto" /> 
                                                <telerik:GridViewDataColumn UniqueName="OrderName" Header="שם&#13;הזמנה" Width="Auto" /> 
                                                <telerik:GridViewDataColumn UniqueName="OrderTotal" Header="סכום הזמנה &#13;(K ש''ח)" Width="Auto" /> 
                                                                                        </telerik:RadGridView.Columns> 
                                        </telerik:RadGridView> 
                                    </StackPanel> 
                                </DataTemplate> 
                            </telerik:RadGridView.HierarchyChildTemplate> 
                        </telerik:RadGridView> 


    private void BindDataMainGrid()  
            {  
                try  
                {  
                     
                    DataSet dataSet = this.GetData();  
     
                    // This is needed to make the grid use the HierarchyChildTemplate  
                    GridViewTableDefinition detailDefinition = new GridViewTableDefinition();  
     
                    // Tell the detailsDefinition to pull its data from the Details DataTable.  
                    detailDefinition.DataSource = dataSet.Tables["Order"].DefaultView;  
     
                    // Specify the relation between the two tables, similar to what is done in the DataSet.  
                    TableRelation tr = new TableRelation();  
                    tr.FieldNames.Add(new FieldDescriptorNamePair("RequestID", "RequestID"));  
                    detailDefinition.Relation = tr;  
     
                    // Add a GridViewTableDefinition to the grid to make it use the HierarchyChildTemplate  
                    // defined in XAML.  
                    if (this.gvRequest.TableDefinition.ChildTableDefinitions.Count < 1)  
                        this.gvRequest.TableDefinition.ChildTableDefinitions.Add(detailDefinition);  
     
                    // Bind the grid to the "master" table.  
                    this.gvRequest.ItemsSource = dataSet.Tables["Request"].DefaultView;  
                }  
                catch  
                {  
                    this.gvRequest.ItemsSource = CommonValues.GetDataTabel().DefaultView;  
                }  
            }  
     
            private void OnChildGridLoaded(object sender, RoutedEventArgs e)  
            {  
                // Pull data from the detail table based on the relation.  
                var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext;  
                var ds = dataRowView.DataView.Table.DataSet;  
                var childData = dataRowView.CreateChildView(ds.Relations["RequestID"]);  
     
                // Manually set the DataContext of the child grid.  
                // We have stopped a wrong DataContext propagating down to this child grid  
                // in the XAML file by wrapping the child grid in a StackPanel and setting  
                // the StackPanel's DataContext to null.  
                ((RadGridView)sender).DataContext = childData;  
     
           }  
     
            private DataSet GetData()  
            {  
                try  
                {  
                    DataSet ds = new DataSet();  
                    dsRequest dsr = ServiceData.GetRequestAndOrder(0,0,1,2009,0);  
                    ds.Tables.Add(dsr.Tables["Request"].Copy());  
                    ds.Tables.Add(dsr.Tables["Order"].Copy());  
                    ds.Relations.Add("RequestID",  
                    ds.Tables["Request"].Columns["RequestID"],  
                    ds.Tables["Order"].Columns["RequestID"]);  
                    return ds;  
                }  
                catch  
                {  
                    return null;  
                }  
     
            } 

     

    Thanks

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 11 Aug 2009 Link to this post

    Hello Orit,

    You can use PreviewDataRecordCreate event to achieve this similar to this example:
    http://demos.telerik.com/wpf/?GridView/Hierarchy/CustomHierarchy

    Kind regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Orit
    Orit avatar
    97 posts
    Member since:
    Jun 2009

    Posted 11 Aug 2009 Link to this post

    Thanks for the quick replay
    in this example you add the child only at runtime
    but I have to add it also in the xaml (since I want to change the header etc.)
    How can I use that PreviewDataRecordCreate ?
    I tried to do the following but the icon is still there

    private void MasterTableDefinition_PreviewDataRowCreate(object sender, DataRecordCreateEventArgs e)  
            {  
                e.IsExpandableRecord = false ;  
            } 
  5. Orit
    Orit avatar
    97 posts
    Member since:
    Jun 2009

    Posted 11 Aug 2009 Link to this post

    Another question, about the design
    I use the ColumnsWidthMode="Fill" property 
    in order to stretch the columns
    In the parent grid it works fine
    but in the child grid it does not work

    <telerik:RadGridView Name="gvRequest" 
                                     xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"   
                                     Width="auto" ColumnsWidthMode="Fill" 
                        AutoGenerateColumns="False" FlowDirection="RightToLeft" ShowGroupPanel="False" IsFilteringAllowed="False">  
                        <telerik:RadGridView.Columns> 
                            <telerik:GridViewDataColumn UniqueName="ActivityID" Header="שם&#13;תת פעילות"  /> 
                            <telerik:GridViewDataColumn UniqueName="RequestID" Header="מספר&#13;דרישה"  /> 
                            <telerik:GridViewDataColumn UniqueName="RequestName" Header="שם&#13;דרישה"  /> 
                            <telerik:GridViewDataColumn UniqueName="RequestTotal" Header="סכום הדרישה &#13;(K ש''ח)" /> 
                            <telerik:GridViewDataColumn UniqueName="RequestType" Header="סוג&#13;הדרישה"  /> 
                            <telerik:GridViewDataColumn UniqueName="Supplier" Header="ספק"  /> 
                            <telerik:GridViewDataColumn UniqueName="RequestBalance" Header="יתרה בדרישה &#13;(K ש''ח)"  /> 
                        </telerik:RadGridView.Columns> 
                            <telerik:RadGridView.HierarchyChildTemplate> 
                                <DataTemplate> 
                                    <StackPanel DataContext="{x:Null}">  
                                            <telerik:RadGridView Name="gvOrder" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"   
                                                                 Width="auto" ColumnsWidthMode="Fill" AutoGenerateColumns="False" ShowColumnHeaders="False"   
                                                                 FlowDirection="RightToLeft" ShowGroupPanel="False" IsFilteringAllowed="False" Loaded="OnChildGridLoaded">  
                                            <telerik:RadGridView.Columns> 
                                                <telerik:GridViewDataColumn UniqueName="ActivityID" Header="שם&#13;תת פעילות"  /> 
                                                <telerik:GridViewDataColumn UniqueName="OrderID" Header="מספר&#13;הזמנה"  /> 
                                                <telerik:GridViewDataColumn UniqueName="OrderName" Header="שם&#13;הזמנה"  /> 
                                                <telerik:GridViewDataColumn UniqueName="OrderTotal" Header="סכום הזמנה &#13;(K ש''ח)"  /> 
                                                <telerik:GridViewDataColumn UniqueName="OrderType" Header="סוג&#13;הדרישה"  /> 
                                                <telerik:GridViewDataColumn UniqueName="Supplier" Header="ספק"  /> 
                                                <telerik:GridViewDataColumn UniqueName="OrderBalance" Header="יתרה בהזמנה &#13;(K ש''ח)"  /> 
                                            </telerik:RadGridView.Columns> 
                                        </telerik:RadGridView> 
                                    </StackPanel> 
                                </DataTemplate> 
                            </telerik:RadGridView.HierarchyChildTemplate> 
                        </telerik:RadGridView> 


    I also try to set Width="100*"  for each column
    and again in the parent its ok in the child not.
  6. Charlie
    Charlie avatar
    24 posts
    Member since:
    Jan 2009

    Posted 11 Aug 2009 Link to this post

    I have the same problem with Filling the columns in the Child Grid as well.  The example from the link below worked in previous versions of the Gridview component, but it does not work for the current version (2009.Q2).  How do we get the Child Grid to Fill like in the old sample.  Can you updated the HierarchyWithMode sample to work with the 2009.Q2 version where it Fills the Child Grid?

    http://www.telerik.com/community/forums/wpf/gridview/styling-childtable-in-hierarchical-grid.aspx

    Thanks,

    Charlie J.
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Aug 2009 Link to this post

    Hello guys,

    Both issues (PreviewDataRecordCreate and ColumnsWidthMode="Fill" for child tables) were confirmed however we will need more time to investigate and fix these.

    Once we are ready I will post update here.

    Greetings,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Meliton Tienda
    Meliton Tienda avatar
    5 posts
    Member since:
    Oct 2009

    Posted 18 May 2010 Link to this post

    I have the same problem with

    ColumnsWidthMode

    and

    PreviewDataRecordCreate

    event,
    I´m use the version  2010.1.515.1030 of telerik controls

    thanks for your help
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 19 May 2010 Link to this post

    Hello,

    These properties were deleted back in Q3 2009. You can use ColumWidth="*" instead ColumnsWidthMode="Fill" and RowLoaded instead PreviewDataRecordCreate - please check our demos for more info.

    All the best,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for WPF is Visual Studio 2017 Ready