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

Postback doesn't remember selection for items with children

5 Answers 113 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Clayton
Top achievements
Rank 2
Clayton asked on 08 Aug 2008, 05:37 PM
When CheckChildNotes = false, the selection of nodes with children are not remembered after a postback. 

IE:  If A.2 and B.3 are selected, on postback, only A.2 is marked

\Node A
        \A.1

        \A.2
        \A.3
\Node B
        \B.1
        \B.2

        \B.3
                \B.3.1
                \B.3.2
                \B.3.3
                \B.3.4

<

telerik:RadTreeView ID="rtvTaxonomies" runat="server" Skin="Default"
              
CheckBoxes="true" SingleExpandPath="True" TriStateCheckBoxes="true"
              
CheckChildNodes="false">
       <
CollapseAnimation Duration="300"></CollapseAnimation>
       <
ExpandAnimation Duration="300"></ExpandAnimation>
</
telerik:RadTreeView>

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Aug 2008, 07:51 AM
Hello Clayton,

This is actually by design. The B3 node has child nodes. After postback they are not checked hence B3 is unchecked. To enable this would mean to completely override the tri-state logic. Imagine the following case:
  1. The user checks A.1 - Node A gets in Indeterminate state
  2. The user checks Node A - Node A gets in Checked state
What should happen after postback? If Node A remains in Checked state this would violate the three state logic (remember that only A1 is checked).

I hope this makes sense.
Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Clayton
Top achievements
Rank 2
answered on 11 Aug 2008, 04:17 PM
I can understand that viewpoint, but also see scenarious (mine for example) in which I am using the treeview to view articles sorted into categories.  The treeview lists the categories.  Each checkbox represents and "AND".  Meaning if A.2 and B.1 are marked, only show articles that are in both categories.  Since we want the generalization of categories, any article in B.3.1 is by default in B.3.  Meaning, if someone checked B.3, they get all articles underneith that folder.  We can't mark all items below as that would then be interpreted differently.

So in short, what I am reading is that I will have to manage the state myself on each postback.
0
Sean
Top achievements
Rank 2
answered on 11 Aug 2008, 05:44 PM
Hi Clayton,

I took a look and am still a bit fuzzy on your seelction requirements. If someone clicks on B3, they get evertything below it, but you don't want the children selected as it is interpreted differently?

What if the select B.3 and B.3.1? Is not B.3.1 already captured by default?

Anyway, I turned off TriState and set CheckChild to false like you did and added a button to execute a postback. All of my seelctions remained checked through postback.

If you do not already have it, get the Telerik Trainer. There is a video for the RadTreeView that shows a databinding of a heirarchial tree. I used it to create the tree and just added an asp:Button at the bottom to execute a postback.

Here is my tree definition:

<telerik:RadTreeView ID="RadTreeView1" runat="server" OnNodeDataBound="RadTreeView1_NodeDataBound" 
            Skin="Hay" CheckChildNodes="false" CheckBoxes="true" MultipleSelect="true" TriStateCheckBoxes="false" PersistLoadOnDemandNodes="true">  
            <CollapseAnimation Duration="100" Type="OutQuint" /> 
            <ExpandAnimation Duration="100" /> 
        </telerik:RadTreeView> 

Like I said, when I click the button, it posts back and the tree remains as desired. I'm not sure why yours does not.

Thanks for listening!

Sean
Electronic Arts, Orlando FL
0
Clayton
Top achievements
Rank 2
answered on 11 Aug 2008, 09:42 PM
The search needs to perform an "AND" opertion on selected items.  Thus following need to occur:

"Give me ALL Informational documents that are associated with sports."
        \Document Type\
                \Informational
                \News
                \Alert
        \Topic\
                \Sports\
                        \Olympics
                        \Track and Field
                        \Water
                        \Marathon  
                \Injuries
                \Awards
        

Since articles are associated with the categories at the lowest level, the database knows following:
        Article A:   Informational, Olympics
        Article B:   Informational, Water
        Article C:   Informational, Alert, Marathon, Injuries
        Article D:   News, Olympics
Articles A, B, and C are valid because they are directly associated with sports and informational document type.



"Give me ALL documents that are both Informational and Alerts and are associated with sports\Marathon and Injuries."
        \Document Type\
                \Informational
                \News
                \Alert
        \Topic\
                \Sports\
                        \Olympics
                        \Track and Field
                        \Water
                        \Marathon  
                \Injuries
                \Awards
        
Here, only article C is to be selected since it is the only one that meets the filter criteria:
        Article A:   Informational, Olympics
        Article B:   Informational, Water
        Article C:   Informational, Alert, Marathon, Injuries
        Article D:   News, Olympics
0
Atanas Korchev
Telerik team
answered on 12 Aug 2008, 07:25 AM
Hello Clayton,

Unfortunately the current implementation of RadTreeView's tri-state logic does not support the behavior you want to achieve. Perhaps you don't need tri-state at all. If you need to check the parent node of a child node you can use some client-side script.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Clayton
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Clayton
Top achievements
Rank 2
Sean
Top achievements
Rank 2
Share this question
or