Getting TreeView CheckedItems

11 posts, 1 answers
  1. Yossi Naar
    Yossi Naar avatar
    14 posts
    Member since:
    Feb 2010

    Posted 14 Mar 2010 Link to this post

    Hi,

    I am trying to get all checked items from the TreeView.
    My problem is this:
    i am using  MyTelerikTree.CheckedItems  to get a list of all the checked elements in the tree.
    my tree has a 3 level deep hierarchy, and i am only interested in the checked items of the deepest level.


    if the tree was never expended i only get the root element as "Checked"
    I assume this is happening because the tree is using virtual elements created on the fly.
    Now, if the root element is fully checked, then it would be safe to assume all children are selected, and that's fine.
    However, if i select just one of the branches or leaves in the tree (so that the root is partially checked) i get it as part of the CheckedItems list.
    This would have been fine as well if the tree was not vitrualizing - i could have simply looked at the deepest checked level.
    the problem is that if the tree is collapsed and i check the root, i only get the root on the CheckedItems.

    In short:
    If i treat a checked element as if all it's children are checked, i will sometimes add unchecked elements
    If i treat  only checked elements as checked (and not the children) i will miss the checked children..

    So my question is - how do i bridge these conflicting issues?


    Thanks,
    Yossi.



  2. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 17 Mar 2010 Link to this post

    Hello Yossi,

    The best practice in your case would be to bind the IsChecked property of your TreeViewItems to a property of the underlying business objects using ContainerBindings. This way even if your upper levels of items haven't been expanded, you will be able to get the checked items on the bottom level. Of course, this approach assumes that you are data binding the TreeView to a source collection.

    Let me know if this would work for you.

    Sincerely yours,
    Tihomir Petkov
    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. UI for WPF is Visual Studio 2017 Ready
  4. Yossi Naar
    Yossi Naar avatar
    14 posts
    Member since:
    Feb 2010

    Posted 17 Mar 2010 Link to this post

    Hi Tihomir ,

    I am very disappointed by your replay.
    I expect a tree control to return the correct list of checked items.
    especially when it has a CheckedItems property.

    I am binding directly to my business objects and i do not want to change my data model due to a bug in the TreeView.

    I will open a support ticket in the hopes it will facilitate a solution.

    Thanks,
    Yossi

  5. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 23 Mar 2010 Link to this post

    Hi Yossi Naar,

    You have correctly identified the reason why some items may be missing from the colelction - they have not been created yet.

    It was a design decision to include the partially checked items in the ChecdkedItems collection as well. The idea was that it may be better to include more items rather than fewer - filgering out the partialyl cahcked items may be easier than searching for them. 

    Technically it is easy for us not to include the partially selected items but this will be a breaking change with regard to the current beahvior.

    I agree that currently there is no easy solution for the conflict in the example that you give.

    One solution that I see here is to for us to introduce a property that will specify whether partially checked items will be included in this collection.

    Do you think that this will work for you?

    Greetings,
    Miroslav
    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.
  6. Yossi Naar
    Yossi Naar avatar
    14 posts
    Member since:
    Feb 2010

    Posted 23 Mar 2010 Link to this post

    Hi Miroslav,

    Well - not getting the partially checked items would certainly help.

    I'd like to point out that i get the chills whenever someone tell's me something is a "design decision".
    A "design decision" is why i am no longer using  infragistics controls (you can look here to see why).

    When something behaves in a wrong and unintuitive  way it is a bug. 
    I am happy to see that at least your documentation accurately reflects it (unlike infragistics).

    I understand the lazy instantiation issue - there is a price to pay for that, and that's reasonable.
    but even if i mark my tree as not virtualizing - the same behavior persists.

    So - for me either of the following would work:

    1. Like you suggested - not getting the partially checked items (by indicating it with some flag)
    2. Allowing some non-virtualizing mode that would return all the checked items, regardless of whether or not  

    Thanks,
    Yossi.




  7. Answer
    Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 23 Mar 2010 Link to this post

    Hello Yossi Naar,

    The CheckedItems can be improved to work better in your case as well. We can call it a bug. In fact I logged it as a bug and it can be tracked here:

    http://www.telerik.com/support/pits.aspx#/public/silverlight/1500

    Thanks for sending the link. When I said that this is a 'design decision' I did not mean it as an excuse not to improve the CheckedItems, on the contrary - we will be happy to make sure that it works in more cases.

    Thank you for your feedback.

    Regards,
    Miroslav
    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.
  8. Yossi Naar
    Yossi Naar avatar
    14 posts
    Member since:
    Feb 2010

    Posted 23 Mar 2010 Link to this post

    Hi,
    Thanks.

    This is a pretty urgent matter for us - when is the next service release?


    Thanks,
    Yossi.
  9. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 24 Mar 2010 Link to this post

    Hello Yossi Naar,

    The change will be included in this week's Internal build on Friday and in the coming SP1 release in the middle of April.

    Regards,
    Miroslav
    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.
  10. Yossi Naar
    Yossi Naar avatar
    14 posts
    Member since:
    Feb 2010

    Posted 22 Apr 2010 Link to this post

    Hi Miroslav.


    According to you previous message the issue should have been fixed a long time ago.
    i just downloaded v 2010.1.0416 (latest build as of today - 22.4.2010) and there has been no improvement or resolution to my problem.

    this issue has become urgent for us.
    what is the status of the fix?

    thanks,
    Yossi.
     
  11. Yossi Naar
    Yossi Naar avatar
    14 posts
    Member since:
    Feb 2010

    Posted 22 Apr 2010 Link to this post

    Hi,

    as i mentioned - this is an urgent issue, so i tried the solution that was suggested by Tihomir Petkov - to bind using the ContainerBindings  - only to discover that it does not exist in the wpf version.

    so i ask for you help again - we need some way of getting the checked state  from the RadTreeView for WPF(!)
    i could not find ANY documented way of getting the checked state of items in the tree. (well - none that does what it's supposed to).

    please respond asap.

    Thanks,
    Yossi.
  12. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 27 Apr 2010 Link to this post

    Hello Yossi Naar,

    Our ContainerBindings are the Silverlight counterpart of Wpf's existing Style bindings. I've prepared and attached a sample project that demonstrates how to use Style bindings and retrieve the checked items in the treeview. Please have a look at it and let me know how it works for you.

    All the best,
    Kiril Stanoev
    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
UI for WPF is Visual Studio 2017 Ready