Collectionviewsource to help ordering Items in treeview

4 posts, 0 answers
  1. LE DREAU Steeve
    LE DREAU Steeve avatar
    74 posts
    Member since:
    Aug 2012

    Posted 13 Apr 2011 Link to this post

    Hi,

    We currently have a problem using treeview, collectionviewsource and drag n drop.
    We need to order our items so we have used a collectionviewsource.
    But we also need drag n drop and what I saw on Internet is that we can't use drag n drop with collectionviewsource.

    Do you have any solution about that please ?

    Thanks

    Regards

    Steeve
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Apr 2011 Link to this post

    Hi LE DREAU Steeve,

    We'll could you please elaborate more on your scenario? Why do you need CollectionViewSource and aren't you able to work with ViewModels only? I usually use CollectionViewSource for grouping Items of same type/property/parent etc. But drag and drop and item from one collection to another is allowed only if the collections are from equal type. Providing a more detailed info of your scenario would be highly appreciated and we would be able to provide with a better advice or workaround. Thank you for your cooperation.

    All the best,
    Petar Mladenov
    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
  3. DevCraft banner
  4. LE DREAU Steeve
    LE DREAU Steeve avatar
    74 posts
    Member since:
    Aug 2012

    Posted 26 Apr 2011 Link to this post

    Hi,

    My scenario is quite simple :
    I have an object tree (with N levels of children). I would like to display this tree into a treeview. Each item must be ordrered alphabetically. So I thought I could do this with collectionviewsource (and it works but the drag n drop functionnality).
    Is there any other way to do this without collectionviewsource ?

    Thanks

    Regards

    Steeve
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 29 Apr 2011 Link to this post

    Hi LE DREAU Steeve,

    Yes, you could implement grouping and sorting without using a CollectionView. You can work with ViewModels and  perform the sorting in them. When retrieving a specific level`s data you can get it sorted like so:
    ObservableCollectio<Item> rootLevel = new ObservableCollection<item>(context.Categories.OrderBy(x=> x.Name));
    Could you please examine this blog post and this demo and let us know if they give you an idea or you need more info?

    Best wishes,
    Petar Mladenov
    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