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

Problem with SelfReference Hierarchy

6 Answers 167 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 1
Kiran asked on 16 Jul 2010, 01:57 PM
I am facing a wierd problem which is showing up also on online WPF sample. I am using following code to populate hierarchy from same table. The grid shows child rows under the parent row and also as another parent row which is causing confusion. I do not want to show the records as parent rows if they have ParentTaskID property set.

 

 

 

 

<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>

6 Answers, 1 is accepted

Sort by
0
Ваня
Top achievements
Rank 1
answered on 16 Jul 2010, 07:16 PM
Hi,Kiran


In your case you should look at the section "Custom hierarchies"-if you want to prevent some rows from being
expandable based on property which is in your case ParentID you should 
attach an event handler to the RowLoaded event of the RadGridview see the following link:

1)http://www.telerik.com/help/wpf/gridview-custom-hierarchies.html

If you encounter any other problems I would also suggest you to look at the following thread:

http://www.telerik.com/community/forums/wpf/gridview/self-referencing-hierarchy-rowloaded-event-on-child-table-definitions.aspx

The case has been resolved and I believe that after researching them you will be able to resolve the issue.

Regards,Vanya

0
Ваня
Top achievements
Rank 1
answered on 16 Jul 2010, 07:18 PM
Hi,Kiran


In your case you should look at the section "Custom hierarchies"-if you want to prevent some rows from being
expandable based on property which is in your case ParentID you should 
attach an event handler to the RowLoaded event of the RadGridview see the following link:

1)http://www.telerik.com/help/wpf/gridview-custom-hierarchies.html

If you encounter any other problems I would also suggest you to look at the following thread:

http://www.telerik.com/community/forums/wpf/gridview/self-referencing-hierarchy-rowloaded-event-on-child-table-definitions.aspx

The case has been resolved and I believe that after researching them you will be able to resolve the issue.

Regards

0
Kiran
Top achievements
Rank 1
answered on 19 Jul 2010, 03:57 PM
My problem is that by default Grid View show all the records as Parents whether they have ParentID or not. The same record is shown as child under that parent. So if you see the record which is a child shows up twice. The effect I want is that Records having ParentID should not be shown unless expanded from its parent.
0
Milan
Telerik team
answered on 20 Jul 2010, 06:58 AM
Hello Kiran,

You can apply a filtering operation which will filter our all items that have ParentID assigned (assuming that -1 is a value indicating that ParentID is not assigned).

<telerik:RadGridView.FilterDescriptors>
    <telerik:FilterDescriptor Member="ParentID" Operator="IsEqualTo" Value="-1"/>
</telerik:RadGridView.FilterDescriptors>


Kind regards,
Milan
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 31 Jul 2010, 04:41 PM
Great. This worked perfectly in my sample application. But my challenge now is that TaskID & ParentTaskID are defined as unique identifier datatype. When I try the same thing in my application it throws caste exception.

<telerik:RadGridView.FilterDescriptors>
                <telerik:FilterDescriptor Member="ParentTaskId" Operator="IsEqualTo" Value="00000000-0000-0000-0000-000000000000"/>
         </telerik:RadGridView.FilterDescriptors>

Is there any solution or workaround for this I can even set ParentTaskID field as null but how would I compare here. If there is no other solution I might have to go back and change the fileds to numeric but it would lead to lot of code changes in my applications.
0
Milan
Telerik team
answered on 02 Aug 2010, 08:46 AM
Hello Kiran,

You can make this work if you can instantiate your unique identifier datatype in XAML. The code should look something like that:

<telerik:RadGridView.FilterDescriptors>
    <telerik:FilterDescriptor Member="Id" Operator="IsEqualTo">
        <telerik:FilterDescriptor.Value>
            <my:ComplexId FirstPart="25" SecondPart="25"/>
        </telerik:FilterDescriptor.Value>
    </telerik:FilterDescriptor>
</telerik:RadGridView.FilterDescriptors>

Also you should override the == and != operators so that IDs are compared correctly. I am attaching a sample project that demonstrates a scenarios similar to yours.

Hope it helps.

Greetings,
Milan
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
Tags
GridView
Asked by
Kiran
Top achievements
Rank 1
Answers by
Ваня
Top achievements
Rank 1
Kiran
Top achievements
Rank 1
Milan
Telerik team
Share this question
or