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. Image for the cookie policy date

Checking Checkboxes in TreeView

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))

4 Replies

NH Nick Howard 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.


GA Gurunathan A Syncfusion Team 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.



JH John Hind 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 ?



JH John Hind 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;




Live Chat Icon For mobile
Up arrow icon