We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Checking Checkboxes in TreeView

Thread ID:





110580 Aug 13,2013 02:54 PM UTC Nov 25,2013 02:47 PM UTC ASP.NET MVC (Classic) 4
Tags: Tools
Nick Howard
Asked On August 13, 2013 02:54 PM UTC

I'm creating a tree and I need to show checkboxes. That works fine. I'm using the code below. My model structure has an id, parentid, and name. So, first I grab the record where the parentid is null and then I recursively find the child records. That all works fine. As part of my model I also have a list of ids where the checkbox needs to be checked. Can I do that in the view? Or do I need to do that in the controller? Or maybe I should ask, do I need to create the TreeView entirely in the controller?

Thanks for any help.

 @helper TreeView(IEnumerable<ItemClass> items)
                    foreach (var item in items) 
                            @Html.DisplayFor(i => item.Name)

                <ul id="treeView" class="visibleHide">
                    @TreeView(Model.Items.Where(o=>o.ParentId == null))

Nick Howard
Replied On August 13, 2013 05:14 PM UTC

I think I need to expand my question a bit. How do I access the tree view on my HttpPost? I have this:

public ActionResult Edit(ViewModel model, TreeViewModel treeViewModel)

treeViewModel is never has any items in it. I'm obviously doing something wrong, but I don't know what it could be. I didn't see any examples that showed how to figure out what's checked. Did I miss one?

Thanks for any help, I really appreciate it.


Gurunathan A [Syncfusion]
Replied On August 23, 2013 10:27 AM UTC

Hi Nick,

Thanks for contacting Syncfusion support.

We have updated with response for the query reported in this forum in the incident 111978 which was created by you. Kindly we request you to follow that incident for further assistance.



John Hind
Replied On November 22, 2013 11:59 AM UTC


I have a similar problem in that I cannot see the items that are checked after the form is submitted. Can you please tell me how to do it ?



John Hind
Replied On November 25, 2013 02:47 PM UTC

Create a hidden input field on the form and then string the checked id's into it. Pick it up in your controller...

<input type="hidden" id="hidCodings" name="hidCodings" />



...then use the following script...

var checked = $find("MyTreeView").GetAllCheckedNodes();


$.each(checked, function (i, nodeitem) {

var nodeid = $("#hidCodings").val() != "" ? $("#hidCodings").val() + "," + $(nodeitem)[0].id : $(nodeitem)[0].id;





This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon