Check uncheck all using virtualization

21 posts, 0 answers
  1. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 11 Oct 2010 Link to this post

    Hi,

    I am using a TreeView with databinding and using virtualization (property isvirtualizing set to true). When I check or uncheck all, the treeview just update the current displayed items. Is there some way to check all items using virtualization?

    best regards,
    Gonçalo
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 14 Oct 2010 Link to this post

    Hello Gonçalo,

    I am not sure how you implement the "check/uncheck all" functionality, but you should keep in mind that when the RadTreeView is virtualized, it creates containers only for those RadTreeViewItems that are insiede the viewport. Therefore, if you set the IsChecked property of the RadTreeViewItem then the operation will only work on the currently displayed items.

    However, if the RadTreeView is databound, you can use ContainerBindings to bind the CheckState property of each RadTreeViewItem to an appropriate business property (read more).

    I hope this information helps. Please let us know if we can further assist you.

    Kind regards,
    Tina Stancheva
    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. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 14 Oct 2010 Link to this post

    I'm using the INotifyPropertyChanged and the ContainerBinding. I think that is working good with items that are currently being displayed. I want for instance check all items, the currently displayed items and the other ones that aren't loaded. Is there a way to do this?

    Regards,
    Gonçalo
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 19 Oct 2010 Link to this post

    Hi Gonçalo,

    The TriState feature of the RadTreeView is exposed to allow such scenarios. However, it only affects the created RadTreeViewItem containers. Therefore, in cases when the RadTreeView is virtualized, this feature won't work.

    Since the virtualization of the RadTreeView means that containers are created only for the RadTreeViewItems inside the viewport, it is best to implement the check/uncheck logic in the view model. For example, you can make sure that every time when a new value is set to a IsChecked business property, the change will affect all children as well.

    I prepared a sample project illustrating this approach. Give it a try and let me know if it works for you or if you need more info.
     
    Greetings,
    Tina Stancheva
    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. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 27 Oct 2010 Link to this post

    Thanks Tina,

    Now if I chekck the parent node it will check the childs. (Its Working)
    But now I think I may have another problem. The RadTreeView CheckedItems property does not have all the items selected.
    I have to the same process to get all the items?


    Kind regards,
    Gonçalo
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 01 Nov 2010 Link to this post

    Hi Gonçalo,

    I am not if I understand your issue correctly. In the sample project I sent the CheckedItems collection is populated as expected. I modified the project slightly to illustrate that. Can you have a look at it and let me know if it works for you.

    Best wishes,
    Tina Stancheva
    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. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 02 Nov 2010 Link to this post

    Hi Tina,

    The problem is in the second layer. If we have another layer: 0.1.2 it dont appear in the Checked items list.
    I send you the exampled with the problem.

    http://www.megaupload.com/?d=P86YWWVV

    Kind regards,
    Gonçalo
  9. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 05 Nov 2010 Link to this post

    Hi Gonçalo,

    This is an expected behavior since the RadTreeView is virtualized and therefore only the visible items' containers are initialized and those are the only items that the RadTreeView is aware of. Therefore the RadTreeView and the RadTreeView.CheckedItems collection isn't aware of any deeper-level checked items.

    However, in the case when the RadTreeView TriStateMode feature is implemented, the RadTreeView evaluates the checked item's immediate children in order to determine the item's proper state. Therefore in the sample project the CheckedItems collection contains only the checked item and its immediate checked children.

    So, indeed, you will need to implement your own logic to keep the checked items in a custom collection.

    Also, I noticed a small issue in my code sample. In the DataItem class implementation I set the child.isChecked private property by mistake. The code should be:
    public bool IsChecked
    {
        get
        {
            return this.isChecked;
        }
        set
        {
            if (this.isChecked != value)
            {
                if (this.Children.Count != 0)
                {
                    foreach (DataItem child in this.Children)
                    {
                        child.IsChecked = value;
                    }
                }
     
                this.isChecked = value;
                OnPropertyChanged("IsChecked");
            }
        }
    }

    I also modified the sample project to illustrate a possible approach towards keeping all checked items in a custom collection. Please give it a try and let me know if it works for you.

    On a side note, I just wanted to ask you to keep in mind that the Virtualization of the TreeView is implemented in order to optimize the Tree's performance when thousands of items have to be displayed. Therefore, if your TreeView is not designed to display a big amount of items, it is better not to virtualize it. I am mentioning that since your scenario requires you to work with the entire collection of items, rather than just with the visible once and since this is against the Virtualization logic, you will have to implement most of your custom logic in the ViewModels.

    I hope the info helps. Please let me know if I can further assist you.

    Sincerely yours,
    Tina Stancheva
    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. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 11 Apr 2011 Link to this post

    Are you saying that with Virtualization turned off that you shouldn't see this behavior? I have the following declaration of the TreeView

    <

     

     

    telerik:RadTreeView MinHeight="100" ItemTemplate="{StaticResource Level1Template}" ItemsSource="{Binding Path=Activities}" IsVirtualizing="False" ItemsOptionListType="CheckList" IsOptionElementsEnabled="True" IsTriStateMode="True" Style="{StaticResource RadTreeViewStyle}">

     

     

    And if I have a collapsed treeview, check a checkbox on the root, then expand the treeview I do not have the children checkboxes checked. See attached image.

  11. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 11 Apr 2011 Link to this post

    Hi,

    Looking into your xaml I think that it should be working. :s
    I'm not an expert, but I will suggest you to try comment the Style={StatickResource}. Maybe is your style. I dont know. 
    Just trying to help you. :)

    Best regards,
    Gonçalo
  12. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 11 Apr 2011 Link to this post

    And I have the SelectionMode=Multiple.
    Try that too.
  13. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 11 Apr 2011 Link to this post

    Thanks for your help but removing the style and SelectionMode=Multiple didn'y help any.

    BTW: I'm using the Q1 2011 release.
  14. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 14 Apr 2011 Link to this post

    Hi Scott,

    @Scott
    Could you please examine my test project and let me know f I have missed something? Thank you for your cooperation.

    Regards,
    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
  15. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 14 Apr 2011 Link to this post

    Hi Petar,
    Yes there was a problem with you example. If you add a ContainerBindingCollection to your HierarchicalDataTemplate it will show the problem. I cannot attach a zip file so I opened a support ticket.

    This is what I have in the XAML from your example that displayes the problem:

        <telerik:ContainerBindingCollection x:Key="BindingsCollection">
            <telerik:ContainerBinding PropertyName="CheckState" Binding="{Binding Path=Checked, Mode=TwoWay}" />
        </telerik:ContainerBindingCollection>
        <telerik:HierarchicalDataTemplate x:Key="Activity_Level3Template" telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}">
            <TextBlock Foreground="DarkBlue" Text="{Binding Path=Name}" />
        </telerik:HierarchicalDataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="Activity_Level2Template" telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}"
                                      ItemTemplate="{StaticResource Activity_Level3Template}" ItemsSource="{Binding Path=Children}">
            <TextBlock Foreground="DarkGreen" Text="{Binding Path=Name}" />
        </telerik:HierarchicalDataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="Activity_Level1Template" telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}"
                                      ItemTemplate="{StaticResource Activity_Level2Template}" ItemsSource="{Binding Path=Children}">
            <TextBlock Foreground="DarkRed" Text="{Binding Path=Name}" />
        </telerik:HierarchicalDataTemplate>
    </Grid.Resources>
    <telerik:RadTreeView MinHeight="100" IsVirtualizing="False" ItemsOptionListType="CheckList" IsOptionElementsEnabled="True" 
                         IsTriStateMode="True" ItemTemplate="{StaticResource Activity_Level1Template}" ItemsSource="{Binding Path=TreeItems}" />
  16. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 15 Apr 2011 Link to this post

    Hi Scott,

    Please take a look at this updated version of Peter's sample and let me know whether it works according to your specifications.

    Regards,
    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
  17. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 15 Apr 2011 Link to this post

    Your example is closer but it still isn't working correctly. May I ask what exactly you changed in the example besides selecting random values in the codebehind?

    Please look at the attached image from your example.
    1) Parent2 is unchecked but all the children are in an intermediate state (invalid state)
    2) Parent3 is checked but all the children are in an intermediate state (invalid state)
    3) Parent4 is in an intermediate state and so are all the children (invalid state)
    4) Play with checking and unchecking the boxes and you will notice that is doesn't behave quite right
  18. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Apr 2011 Link to this post

    Hi Scott,

    Please first accept our apologies for not being clear in our previous posts.
    Actually we are aware of this issue and we have logged it in our PITS. The real problem is that currently when using the TriState mode of the RadTreeView and ContainerBindings, the bindings are with higher priority. So currently, when using container bindings, you will have to take care of the implementation of tristate logic on your own. We will implement this to be realized out of the box but we cannot provide an estimated time for this issue. You can now vote for it and this way increase its priority. 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
  19. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 17 May 2011 Link to this post

    Is there any idea on when this will be fixed? I was hoping not to implement TriStates myself. I have tried other workarounds like looking at checked items but those are also virtualized and I cannot use it.

    This seems like a very fundamental feature of the TreeView which is not working correctly.

    Thanks for any consideration.
  20. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 May 2011 Link to this post

    Hello Scott,

    We will work on RadTreeView`s issues after the official Q2 2011 release scheduled for the middle of July.
    Please accept our apologies for any inconvenience caused.

    Kind regards,
    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
  21. Mike
    Mike avatar
    10 posts
    Member since:
    Jun 2011

    Posted 29 Sep 2011 Link to this post

    Has this problem been corrected?  I'm using ContainterBindings on a RadTreeView, and this problem is still manifesting itself.  We updated to the most recent version of the telerik tools two days ago.  The problem only seems to be there before I expand a particular branch.  So if I set the CheckedState in a node with children before it has ever been expanded, it will not propagate to the children, but if I expand and collapse that branch, then change the check state programatically, it works.  Any idea when this will be fixed?
  22. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 04 Oct 2011 Link to this post

    Hello Mike,

     Unfortunately, we cannot provide an estimated time frame when this will be resolved. As a workaround we highly suggest you to implement the TriState logic in your ViewModels on your own. As for the CheckState setting before the items is generated, we cannot determine this as a bug because this is expected by design. We described this behaviour in this forum thread.
    Please let us know if you have further questions.

    Regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner