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

SelfReference Hierarchy Problem With Dynamic Columns

6 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 1
Kiran asked on 07 Sep 2010, 07:22 AM
Hi

I am implementing self reference hierarchy and i have used the code below which works fine for default columns.
<telerik:RadGridView x:Name="RadGridView1"
     DataLoading="RadGridView1_DataLoading" RowLoaded="RadGridView1_RowLoaded" GridLinesVisibility="Horizontal" 
    CanUserFreezeColumns="False" IsReadOnly="True" AutoGenerateColumns="False" Margin="10">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn  DataMemberBinding="{Binding TaskId}" />
          
        <telerik:GridViewDataColumn Header="Task Name" DataMemberBinding="{Binding TaskName}" />
        <telerik:GridViewDataColumn Header="Read">
            <telerik:GridViewColumn.CellTemplate>
                <DataTemplate>
                    <CheckBox x:Name="checkBoxRead" IsChecked="{Binding Read}" />
                </DataTemplate>
            </telerik:GridViewColumn.CellTemplate>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn Header="Write">
            <telerik:GridViewColumn.CellTemplate>
                <DataTemplate>
                    <CheckBox x:Name="checkBoxWrite" IsChecked="{Binding Write}" />
                </DataTemplate>
            </telerik:GridViewColumn.CellTemplate>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
    <telerik:RadGridView.FilterDescriptors>
        <telerik:FilterDescriptor Member="ParentTaskId" Operator="IsEqualTo"  Value="0"/>
    </telerik:RadGridView.FilterDescriptors>
    <telerik:RadGridView.ChildTableDefinitions>
        <telerik:GridViewTableDefinition>
            <telerik:GridViewTableDefinition.Relation >
                <telerik:TableRelation IsSelfReference="True"     >
                    <telerik:TableRelation.FieldNames>
                        <telerik:FieldDescriptorNamePair  
                            ParentFieldDescriptorName="TaskId" 
                            ChildFieldDescriptorName="ParentTaskId" />
                    </telerik:TableRelation.FieldNames>
                </telerik:TableRelation>
            </telerik:GridViewTableDefinition.Relation>
        </telerik:GridViewTableDefinition>
    </telerik:RadGridView.ChildTableDefinitions>
      
</telerik:RadGridView>

I have a problem when I add dynamic columns columns are showing at rool level but does not get added at child node level. If you notice in the screenshot RolePermissions[0], RolePermissions[1], RolePermissions[2] are dynamic columns. I have attached the screenshot. Is there a simple way to fix it please suggest.

Regards
Kiran


6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 07 Sep 2010, 07:25 AM
Hi,

 Can you post more info how exactly these columns are added?

Regards,
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
0
Kiran
Top achievements
Rank 1
answered on 07 Sep 2010, 07:47 AM
Hi

I am adding columns using this code.

GridViewDataColumn tempDataColumn = new GridViewDataColumn();
  
            // Determines the maximum number of months that any employee has worked.
            int maxNumberOfMonths = Tasks.Max((x) => x.RolePermission.Count);
            for (int i = 0; i < maxNumberOfMonths; i++)
            {
  
                tempDataColumn = new GridViewDataColumn()
                {
                    UniqueName = "Read" + (i + 1)
                    ,
                    DataMemberBinding = new Binding("RolePermission[" + i + "]") { Mode = BindingMode.TwoWay }
                    ,
                    DataType = typeof(bool)
                };
  
                tempDataColumn.IsReadOnly = false;
  
                this.RadGridView1.Columns.Add(tempDataColumn);
            }

Regards
Kiran
0
Vlad
Telerik team
answered on 07 Sep 2010, 08:10 AM
Hello,

 This will add columns only for the parent grid - not for child grids. You can use DataLoading if you want to add columns for both parent and child grids. 

Best wishes,
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
0
Kiran
Top achievements
Rank 1
answered on 07 Sep 2010, 09:17 AM
Hi

I was only using on grid and did not use any child grids. How do i access child grid object during that event. Can you post some sample code or related solution?

Regards
Kiran
0
Accepted
Vlad
Telerik team
answered on 07 Sep 2010, 09:20 AM
Hello,

 Have you checked the code in this demo?

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
0
Kiran
Top achievements
Rank 1
answered on 07 Sep 2010, 02:33 PM
Hi

This demo helped thought i had tweak slighly to support multi level hierarchies.

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