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

Check uncheck all using virtualization

20 Answers 247 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Pedro
Top achievements
Rank 1
Pedro asked on 11 Oct 2010, 06:54 PM
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

20 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 14 Oct 2010, 06:18 PM
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
0
Pedro
Top achievements
Rank 1
answered on 14 Oct 2010, 06:56 PM
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
0
Tina Stancheva
Telerik team
answered on 19 Oct 2010, 03:50 PM
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
0
Pedro
Top achievements
Rank 1
answered on 27 Oct 2010, 01:42 PM
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
0
Tina Stancheva
Telerik team
answered on 01 Nov 2010, 11:12 AM
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
0
Pedro
Top achievements
Rank 1
answered on 02 Nov 2010, 11:49 AM
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
0
Tina Stancheva
Telerik team
answered on 05 Nov 2010, 01:35 PM
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
0
Scott
Top achievements
Rank 1
answered on 11 Apr 2011, 06:15 PM
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.

0
Pedro
Top achievements
Rank 1
answered on 11 Apr 2011, 06:55 PM
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
0
Pedro
Top achievements
Rank 1
answered on 11 Apr 2011, 06:58 PM
And I have the SelectionMode=Multiple.
Try that too.
0
Scott
Top achievements
Rank 1
answered on 11 Apr 2011, 07:01 PM
Thanks for your help but removing the style and SelectionMode=Multiple didn'y help any.

BTW: I'm using the Q1 2011 release.
0
Petar Mladenov
Telerik team
answered on 14 Apr 2011, 04:20 PM
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
0
Scott
Top achievements
Rank 1
answered on 14 Apr 2011, 08:03 PM

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}" />
0
Kiril Stanoev
Telerik team
answered on 15 Apr 2011, 10:09 AM
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
0
Scott
Top achievements
Rank 1
answered on 15 Apr 2011, 05:08 PM
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
0
Petar Mladenov
Telerik team
answered on 18 Apr 2011, 01:41 PM
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
0
Scott
Top achievements
Rank 1
answered on 17 May 2011, 08:40 PM
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.
0
Petar Mladenov
Telerik team
answered on 19 May 2011, 04:36 PM
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
0
Mike
Top achievements
Rank 1
answered on 29 Sep 2011, 07:17 PM
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?
0
Petar Mladenov
Telerik team
answered on 04 Oct 2011, 01:39 PM
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 >>

Tags
TreeView
Asked by
Pedro
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Pedro
Top achievements
Rank 1
Scott
Top achievements
Rank 1
Petar Mladenov
Telerik team
Kiril Stanoev
Telerik team
Mike
Top achievements
Rank 1
Share this question
or