It would be very helpful to have a sample part of your DEMO, showing RADTreeview working with WCF RIA Services using the new collection (QueryableDomainServiceCollectionView ) from RADDataSource for RIA Services.
10 Answers, 1 is accepted
Hi Ben, I feel your pain. I tried binding my RadTreeListView directly to a QueryableDomainServiceCollectionView exposed by my view model but I had quite a bit of trouble with this because the EntityQuery I use returns all of my objects, not just the top-level one. So I saw all of my entities displayed at the top level, not just my root node.
My entities (and yours too, I suppose) have parent-child relationships by virtue of a self-referencing parentId which is defined at the database level, detected by the Entity Framework and honoured by the RadDomainDataSource. It seemed potentially elegant to make use of those relationships, but I couldn't find any properties or events of the QueryableDomainServiceCollectionView that would help me to restrict the top-level objects to just those where the parent object is null.
I got something working in the end - it doesn't feel particularly neat, but the following may work for you, too:
I hooked the LoadedData event of my QDSCV, and in there I iterated through all of the Entities returned. If I found one with no Parent, I stored it in an ObservableCollection created just to hold references to the top-level Entities...
I then exposed the top-level entities through a view model property:
This is the property my RadTreeListView bound to. I didn't bind to the QDSCV like all the Telerik examples:
It seems it was enough to bind to the ObservableCollection of top-level elements, then the RadTreeListView just followed the ChildPlantElementCollection property downwards from there.
Hope there's enough similarity with your case to be of some help.
Yes, the self referencing is the part that I'd like to see a solution from Telerik and rather than creating separate collection for the top level. In my case, similar to Desktop File Directory, where the user can create deeper folders, I need all to be in one collection and at the same (if possible) take advantage of LoadOnDemand feature. I'll look at the code in more detail later on.
Let's see what team has to say and offer with the new QDSCV.
Thank you again.
I'd like to extend my request that any demo or docs provided for my request would also describe and highlight using QDSCV in relation to TreeView's ItemsControl and Containers.
TreeView seems to be very deep and I'm trying to minimize the learning curve while using it with RIA services and QDSCV.
Your help will be appreciated.
The QDSVC is just a collection it will work with RadTreeView. However, the collection is not hierarchical so you'll need to implement this with your custom logic. The closest example that we have for this you can find here: ttp://demos.telerik.com/silverlight/#DataVirtualization/VariousControls.
Please let us know if that is helpful to you.
the Telerik team
Thanks for the link. I had not seen this demo before, since I was mainly looking at the TreeView section.
This demo raises another question regarding the difference between "Virtualization" and "LoadOnDemand" features for TreeView.
I'm trying to figure out what steps I need to follow in order to use TreeView successfully. There are too many things in TreeView and there is no guidance how these need to be coordinated. For Example, we have:
a) Hierarchical steps to implement
b) adding Self Referencing to it.
c) Building the proper hierarchical template.
d) Then addressing "LoadOnDemand"
e) Then Virtualization.
f) Then making sure the TreeView and Data provider stay in synch.
g) and other things.
I don't think the answer "The QDSVC is just a collection it will work with RadTreeView" gives a good explanation to above steps that are not clearly outlined in the docs. A complex control like TreeView needs some guidelines rather letting each person trying to figure out how the pieces need to be together. It just too much waste of time.
Generally QueryableDomainServiceCollectionView is not different compared to any other standard collection since this collection is not hierarchical - we do not have any hierarchical collection so far.
To achieve your goal you can create a model with nested QueryableDomainServiceCollectionView similar to the example with RadTreeView and VirtualQueryableCollectionView - you can check the code in ExamplesDataContext class.
the Telerik team
Thanks for the pointer. I just opened the sample project to look at that class.
As I had asked Alex, how does Virtualization concept come into play with the LoadOnDemand feature and how should they both be coordinated?
I think not having clear picture of these all coming into one scene, make it harder to layout the path.
p.s. If I'm doing a self referencing hierarchical treeview, do I still need to use Virtualization? The above mentioned sample seems to be dealing with multiple tables for hierarchial case. In my case, it's a single table using ID, ParentID for self referrencing to create Hierarchical.
The Virtualization feature of RadTreeView controls how many RadTreeViewItems will be rendered on the screen. As any other virtualized control, RadTreeView will render only those RadTreeViewItems that are visible.
The LoadOnDemand feature allows you to assign ItemsSource to a RadTreeViewItem whenever you expand this RadTreeViewItem.
The best practice is to always turn on the Virtualization whenever your RadTreeView has a lot of items (no matter if you are using LoadOnDemand, binding RadTreeView to hierarchical data source or whatever).
the Telerik team
I hope the online docs gets more updated on the guidance and the "Why" part of things, to avoid confusion.