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

[Solved] Cannot post MVC TreeView with check boxes and loaded on demand nodes

1 Answer 38 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Todd
Top achievements
Rank 1
Todd asked on 09 Sep 2011, 03:52 AM
I have a TreeView configured to load nodes on demand and use check boxes as shown:
@(Html.Telerik().TreeView()
        .Name("SiteSelector")
        .ShowCheckBox(true)
        .BindTo(new[] { Model }, (item, web) =>
        {
            item.Text = web.Title;
            item.Value = web.Url;
            item.LoadOnDemand = web.HasSubWebs;
        })
        .DataBinding(dataBinding => dataBinding.Ajax().Select("LoadSubSites", "Taxonomy"))
)
I have on demand loading working. However, whenever I submit the form to my controller, I get a null List<TreeViewItem> instance. My controller signature looks like the following:
[HttpPost]
public ActionResult Create(TaxonomyCreateEditViewModel viewModel, List<TreeViewItem> checkedSites)
{
        ...
}
My own model comes across correctly but the list of nodes is null.

Using Fiddler I can see the checked nodes are being sent across. In addition to values from my model, I see values in the post data like:

SiteSelector_checkedNodes.Index=0
SiteSelector_checkedNodes%5B0%5D.Checked=true

...and so on for each checked node.

Any ideas?

1 Answer, 1 is accepted

Sort by
0
Todd
Top achievements
Rank 1
answered on 09 Sep 2011, 08:57 PM
Found the problem, the List<TreeViewItem> parameter of my controller had to be named "SiteSelector_checkedNodes" where SiteSelector is the name of my TreeView. Worked like a charm after that.
Tags
General Discussions
Asked by
Todd
Top achievements
Rank 1
Answers by
Todd
Top achievements
Rank 1
Share this question
or