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

Parent item wrong checkbox state

3 Answers 40 Views
Window
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 23 Sep 2011, 04:47 PM
Hi,

I have a RadTreeView with items and subitems:

All
    1
        1.1
        1.2
        1.3
    2
        2.1
        2.2
        2.3

Each subitem are associated to a RadTabControl/RadTabItem. When an item was checked in my treeview, I create dynamically a RadTabItem and when a user uncheck and item in my treeview, I remove it's associated RadTabItem from RadTabControl.

The problem is, when the user try to uncheck the item associated with the active RadTabItem in my RadTabControl, in my PreviewUnchecked event, I set the e.Handled property to true to prevent the remove of my RadTabItem in my Unchecked event.

Here is the piece of code:

 

private void radTreeViewDepartments_Unchecked(object sender, Telerik.Windows.RadRoutedEventArgs e)

 

{

 

RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;

 

 

//Remove a page if it's the lowest level item and if it's not the active tab.

 

 

if (item != null && !item.HasItems && item.Tag != null)

 

{

(item.Tag

as RadTabItem).Content = null;

 

RadTabControlDepartments.Items.Remove(item.Tag);

item.Tag =

null;

 

}

}

 

private void radTreeViewDepartments_PreviewUnchecked(object sender, RadRoutedEventArgs e)

 

{

 

RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;

 

 

//Check if it's not the active tab, if it's the active tab, the routedevent was stop.

 

 

if (item != null && !item.HasItems && item.Tag != null)

 

{

 

if (item.Tag == RadTabControlDepartments.Items[RadTabControlDepartments.SelectedIndex])

 

{

e.Handled =

true;

 

}

}

}


If the subitem "1.1" correspond the my active tab in my RadTabControl and the user unchecked the subitem "1" in my RadTreeView, both subitems "1.2" and "1.3" become unchecked and the subitem "1.1" stay checked but the subtiem "1" become unchecked to indicate me that all the subitems should be unchecked!!!

If I try to unchecked subitems "1.3", "1.2" and "1.1" manually, of course subitem "1.1" stay checked and the state of the subitem "1" stay correct!!!

Thank's

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 28 Sep 2011, 02:35 PM
Hello Oliver,

 As I managed to understand , you don't want to use the default TriState mode of the RadTreeView. So you want something like customized TriState Mode , am I right? Is it possible for you open a new support thread with a project attached and more details on what you try to achieve so that we would be better able to help you? I think your scenario is suitable for using an MVVM approach, both TreeView and TabControl depend on a properties that could be part of a ViewModel. On the other hand you can implement your own TriState ( and customize it) in the ViewModels. You can check out this code library project.

All the best,
Petar Mladenov
the Telerik team

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

0
Oliver
Top achievements
Rank 1
answered on 29 Sep 2011, 03:07 PM
Hi,

it's not really something I'm trying to do but something that I think it's a strange behaviour when a specific pattern was respected!!!

Here is the pattern:

All items
        Item #1
                Item #1.1
                Item #1.2
                Item #1.3
        Item #2
                Item #2.1
                Item #2.2
                Item #2.3

Attached to my RadTreeView, I have a "PreviewUnchecked" event. in some circumstances, I want to prevent item to be uncheck, when this occur, I set the e.Handled property to true.

Assume in this pattern that all items was checked and "Item #1.1" can't be unchecked. So, "Item #1" have a state to represent that all subitems is check, if I try to uncheck all subitems of "Item #1", the visual state of "Item #1" change to inform me that not all subitems was checked and of course in my "PreviewUnchecked" event, I manage the fact that "Item #1.1" cannot be uncheck.

So, if I uncheck directly "Item #1", "Item #1.1" stay check, ", "Item #1.2" and "Item #1.3" become uncheck but parent item "Item #1" become totally uncheck even if "Item #1.1" stay checked!!!! Why???

Thank's
0
Petar Mladenov
Telerik team
answered on 04 Oct 2011, 01:22 PM
Hi Oliver,

 We managed to reproduce this behaviour in the RadTreeView and we logged this as a bug in our PITS. We also updated your telerik account points. As a workaround we, suggest you to use custom TriState logic and ViewModels as done in the code library project. Please accept our apologies for the inconvenience caused.

Best wishes,
Petar Mladenov
the Telerik team

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

Tags
Window
Asked by
Oliver
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Oliver
Top achievements
Rank 1
Share this question
or