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

Hierarchy issue using PropertyRelation

4 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonny
Top achievements
Rank 1
Jonny asked on 29 Jun 2009, 04:20 PM
Hi,

I'm using PropertyRelations to bind a hierarchical grid.  This all works fine, except if the collection that the child grid binds to is empty.  In this case, the + symbol is still shown, and on expanding the parent row a very large empty grid is shown within.  What I need is for the + symbol not to be displayed when the collection is empty.

I've tried trapping TableDefinition.PreviewDataRecordCreate to see if I can set IsExpandableRecord, but this event doesn't seem to be thrown when using PropertyRelations.

Please advise how I can do this.

Let me know if you need a sample project or more details.  This is the last issue outstanding, and I should be placing an order if you can get this one resolved.

Thanks,

Ben Jackson
BlueHub Solutions

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 30 Jun 2009, 06:24 AM
Hello Ben,

In this demo we used exactly PropertyRelation to achieve custom hierarchy.

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.
0
James
Top achievements
Rank 1
answered on 22 Sep 2009, 07:49 AM
Hi Vlad,

I'm looking at using the GridView for displaying hierarchical data based on related ObservableCollection<T> objects.

Your previous demo works very well for child rows that are added dynamically, the child grids are added as expected when new child rows are added to a parent collection, when reacting to the PreviewDataRecordCreate event.

I would like to do the reverse of this, so when the last child row is removed from a parent collection, the grid is removed also, except there is no matching event PreviewDataRecordRemove.

I have tried storing away the TableDefinition objects for each row into a Dictionary (see example below), and clearing its parent TableDef collection when the last child row is removed, but this has no effect, the child grid still appears (the row is removed, but the grid including the headers remain). Do you have any suggestions for achieving this?

        void CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) {  
            var collection = sender as ICollection;  
            if (collection.Count == 0) {  
                var order = e.OldItems[0] as Order;  
                var parentData = order.Parent;  
                if (tableDefinitionDictionary.ContainsKey(parentData)) {  
                    var tableDef = tableDefinitionDictionary[parentData];  
                    tableDef.Clear();  
                }  
            }  
        } 

Hope this makes sense, I can post a project if required.

Regards,

James.
0
Vlad
Telerik team
answered on 25 Sep 2009, 07:17 AM
Hi James,

You can call Rebind() for the parent grid and PreviewDataRecordCreate will be raised again where you can check if there are any items in the child property.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
James
Top achievements
Rank 1
answered on 27 Sep 2009, 01:21 AM
Thanks Vlad, just what I was looking for :)
Tags
GridView
Asked by
Jonny
Top achievements
Rank 1
Answers by
Vlad
Telerik team
James
Top achievements
Rank 1
Share this question
or