This is a migrated thread and some comments may be shown as answers.
Updating TreeView with values from DropDownList (Ajax)
0 Answers 37 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Benjamin
Top achievements
Rank 1
Benjamin asked on 11 Nov 2010, 05:02 PM
Hello,

is there an elegant way to update a TreeView with values from a DropDownList via an AjaxRequest?
I have the following code and no idea how to solve this in a good way:

<div class="editor-label">
    <%= Html.LabelFor(m => m.ClassificationSystems) %>
</div>
  
<div class="editor-field">
    <%= Html.Telerik().DropDownList()
                      .Name("systemsDropDown")
                      .BindTo(Model.ClassificationSystems)
                      .ClientEvents(events => events.OnChange("systemsDropDown_onChange"))
    %>
</div>
  
<div class="editor-label">
    Klassifikation
</div>
  
<div class="treeview-container">
    <%= Html.Telerik().TreeView()
                        .Name("ClassificationsTreeView")
                        .BindTo(Model.ClassificationRootNodes, (item, treeViewItem) =>
                        {
                            item.Text = treeViewItem.Text;
                            item.Value = treeViewItem.Value;
                            item.LoadOnDemand = treeViewItem.LoadOnDemand;
                            item.Enabled = treeViewItem.Enabled;
                        })
                        .DataBinding(dataBinding =>
                        {
                            dataBinding.Ajax()
                                       .Enabled(true)
                                       .Select("_AjaxClassificationsTreeViewBinding", "Home");
                        })
    %>
</div>
  
<div class="editor-label">
    <input type="button" value="Klassifikation bearbeiten" />
</div>
  
<script type="text/javascript">
    function systemsDropDown_onChange() {
        var treeviewitem = $('#ClassificationsTreeView');
        var treeview = treeviewitem.data('tTreeView');
          
        treeview.ajaxRequest(treeviewitem);
    }
</script>



It would be very cool to get the selected value of the DropDownList into this Method:
[HttpPost]
public ActionResult _AjaxClassificationsTreeViewBinding(TreeViewItem node)
{
    return new JsonResult { Data = new List<TreeViewItem>() };
}


Any suggestions?

Regards, Benjamin

Tags
TreeView
Asked by
Benjamin
Top achievements
Rank 1
Share this question
or