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

[Solved] How to get checked child nodes on form post

11 Answers 332 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
walid
Top achievements
Rank 1
walid asked on 25 May 2010, 12:34 PM
Hi,
I'am building an hierarchical treeview that support checkboxes,however when i select a parent node and his childs i'am having only the parent on my controller action when form is posted.  
So how  can i get all checked nodes on my treeview whatever was his level?
Hope to get a quick answer
Thanks on advance for your help.

WALID

11 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 25 May 2010, 12:49 PM
Hi walid,

Our online example works as expected. Have you tried it? What is different in your case?

Regards,
Atanas Korchev
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
walid
Top achievements
Rank 1
answered on 25 May 2010, 01:02 PM
Hi Atanas,
Well the difference i'am using an additionnal script to get child nodes selected when parent is checked
and a multi root nodes in my treeview.
In fact i was following your online exemple but still have this problem.

Here a Treeview code :
...  
<% List<TreeViewItemModel> checkedNodes = ViewData["checkedNodes"] as List<TreeViewItemModel>;%> 
            <%= Html.Telerik().TreeView()  
                    .Name("TreeView")  
                    .ShowCheckBox(true)  
                    .ExpandAll(true)  
                    .BindTo(ViewData[Keys.UserAccesRightList] as IEnumerable<MvcAdmin.Models.TreeNode>mappings => 
                      {  
                          mappings.For<MvcAdmin.Models.TreeNode>(binding => binding  
                                   .ItemDataBound((item, node) => 
                                   {  
                                       item.Text = node.Name;  
                                       item.Value = node.NodeId.ToString();  
                                         
                                       if (checkedNodes != null) {  
                                           item.Checked = checkedNodes.Where(e => e.Value.Equals(node.NodeId.ToString())).FirstOrDefault() != null;   
                                       }  
                                   })  
                                   .Children(e => e.Children));  
 
                          mappings.For<MvcAdmin.Models.TreeNode>(binding => binding  
                                   .ItemDataBound((item, node) => 
                                   {  
                                       item.Text = node.Name;  
                                       item.Value = node.NodeId.ToString();  
 
                                       if (checkedNodes != null)  
                                       {  
                                           item.Checked = checkedNodes.Where(e => e.Value.Equals(node.NodeId.ToString())).FirstOrDefault() != null;  
                                       }  
                                   }));                          
                      })  
                      
            %> 

Thanks

WALID
0
Atanas Korchev
Telerik team
answered on 25 May 2010, 01:13 PM
Hello walid,

Your code looks valid and should not be related with posting node checked state. Unfortunately I cannot tell why posting may not work in your case - everything looks normal based on the provided info.
I suggest you send us a sample project which shows the problem you are having. Since attachments are allowed only to support tickets you should host the project in some public web hosting site (rapidshare.com, mediafire.com etc).

Regards,
Atanas Korchev
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
walid
Top achievements
Rank 1
answered on 25 May 2010, 02:01 PM
Hi Atanas ,
Well when getting the TreeViewItemModel node (witch is the parent node) in posting , it comes with items.Count==0 even when it has selected child nodes.Is it supposed to comes in that way , i mean a flat list of TreeViewItemModel ?
Could you provide me a sample project that works fine in this case other than the online one?

Thanks again

WALID
0
Atanas Korchev
Telerik team
answered on 25 May 2010, 02:08 PM
Hi walid,

This is by design. The list is indeed flat as shown in our online demo.

Regards,
Atanas Korchev
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
walid
Top achievements
Rank 1
answered on 25 May 2010, 03:29 PM
Hi Atanas,
Here some more informations about what i'am expecting :
First i 'am using MVC v1.x and that's probably why your online demo wont work in my case.
In other hand i'am using a script witch you provide us in previous topic for selecting child checkboxes when parent is selected.
http://www.telerik.com/community/forums/aspnet-mvc/treeview/how-to-get-child-checkboxes-selected-when-parent-checkbox-is-selected.aspx
So what i need is to get the values from the selected nodes in the treeview.
Any Help would be appreciated ?
Thanks
WALID
0
Accepted
Georgi Krustev
Telerik team
answered on 26 May 2010, 03:27 PM
Hello walid,

After further investigation we were able to reproduce the described issue. In MVC 1.0 you can retrieve only checked nodes from the first level of TreeView.

Could you please share with us the reason why you do not want to update to MVC 2.0?
Thus we will avoid this erroneous behavior.

All the best,
Georgi Krustev
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
walid
Top achievements
Rank 1
answered on 27 May 2010, 09:21 AM
Hi there,

Well obviously the problem was with mvc 1.I just find out that mvc 1 can't parse or don't recognize a mutli dimmentionnel array (matrix) used by your treeview to define hierarchical implementation.that's why its just recongnize only first parent because it's defined in a simple array <input name="checkedNodes[0].Value" ... and can't parse child nodes as <input name="checkedNodes[0:0].Value"...
So you right, the solution is to upgrade to mvc 2 and i'am doing it .

Thanks for your help and your reactivity again.

WALID
0
walid
Top achievements
Rank 1
answered on 27 May 2010, 12:09 PM
Hi Georgi ,
After upgrading an ASP.NET MVC 1.0 application that uses the Grid MVC Extensions (build 2009_3_1110) to ASP.NET MVC 2.0 ... I am getting now the following MissingMethodException that was not occuring previously.

Method not found: 'System.Collections.Generic.IDictionary`2<System.String,System.Web.Mvc.ValueProviderResult> System.Web.Mvc.ControllerBase.get_ValueProvider()'.

Thanks

WALID
0
Accepted
Atanas Korchev
Telerik team
answered on 27 May 2010, 12:14 PM
Hello walid,

Check this help topic.

All the best,
Atanas Korchev
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
Shawn
Top achievements
Rank 2
answered on 17 Jun 2012, 10:17 PM
What approach would you recommend I use in a scenario in which I have multiple treeviews on my form?  I'd to have one submit button for the form, and then be able to evaluate the different treeviews separately in my controller.
Tags
TreeView
Asked by
walid
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
walid
Top achievements
Rank 1
Georgi Krustev
Telerik team
Shawn
Top achievements
Rank 2
Share this question
or