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

Displaying Tree View in drop-down

Hi,

I am working ASP .NET MVC4. I would like to display Tree View data in drop-down. Could you please help me on this?

Example, I want to display data in drop-down as shown below. 
        Parent Node
            -->Child Node1
                        -->ChildNode11
                        -->.................
            --> Child Node2
            --> ............

The levels under Parent Node will be dynamic.

Thanks in advance.

Regards,
Siva

7 Replies

ME Meena Syncfusion Team January 9, 2013 05:35 AM UTC

Hi Sivakumar,

Thanks for contacting Syncfusion forums.

Your requirement of placing the treeview control inside a dropdown can be achieved by placing our TreeView control within our GenericDropdown control. Please refer the below code snippet.

<code>

  <div id="drop-down-contents" style="visibility: hidden">

    <%=Html.Syncfusion().TreeView("tree")  %>                   

   </div>

    

    <%=Html.Syncfusion().GenericDropDown("myDropDown")

       .TargetContentId("drop-down-contents")%>

</code>

In the above code,  the treeview contents are loaded dynamically in controller page . You can also load the treeview contents in view page itself. Please refer the below online UG link for creating the TreeView control and GenericDropdown control and their various features.

http://help.syncfusion.com/ug/asp.net%20mvc/tools/default.htm#!documents/genericdropdown.htm

http://help.syncfusion.com/ug/asp.net%20mvc/tools/default.htm#!documents/treeview.htm

We have also prepared a simple sample with the above requirement for your  convenience and it can be downloaded from the below link.

Please let us know if you have any other concerns.

Regards,

Meena



GenericDropDown_6b0f033c.zip


SI Sivakumar January 10, 2013 09:00 AM UTC

Hi Meena,

Thanks for the Solution. I tried with above solution in my application. It's working fine but I am facing one problem. I am loading this drop down based on user selection on other control. So when I change my selection it's appending with Old Tree View. So how can I reset Drop down items when selection changes?

Thanks in advance.

Regards,
Siva


ME Meena Syncfusion Team January 15, 2013 04:25 PM UTC

Hi Sivakumar,

 

Thanks for the update.

 

We have modified the previous sample to meet your requirement of rendering different treeview within Genericdropdown control based on user selection and it can be downloaded from the below link.

 

In the attached sample, we have a simple dropdown with three items. Based on its selection, different treeview will be rendered within Genericdropdown.

 

Kindly have a look at the sample and let us know if it helps.

 

Regards,

Meena



GenericDropDown_130b1ad9.zip


SI Sivakumar February 18, 2013 09:40 AM UTC

Hi Meena,

I tried with above solution and it's working fine now. Thanks for the solution.

Regards,
Siva


ME Meena Syncfusion Team February 18, 2013 10:26 AM UTC

Hi Siva,

 

Thanks for the update.

 

Kindly get back to us if you need further assistance. We will be happy to help you out.

 

Regards,

Meena



SA Samantha October 19, 2016 05:54 AM UTC

I am also trying to do the same thing. but i cant downloaded sample. why is that?


DT Dhivyalakshmi Thirumurugan Syncfusion Team October 20, 2016 10:16 AM UTC

Hi Samantha, 

The above given download link got broken due to data lost in our end . But you can find the live demo for this query in our demo site. Kindly check the below link.  


Also you can get the same online demo sample from your installed location. 

Please let us know if you have any queries. 

Regards, 
Dhivyalakshmi. 


Loader.
Live Chat Icon For mobile
Up arrow icon