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.
Unfortunately, activation email could not send to your email. Please try again.

Tree View and custom List as DataSource

Thread ID:

Created:

Updated:

Platform:

Replies:

113742 Oct 7,2013 07:57 AM Oct 17,2013 06:38 AM ASP.NET MVC (Classic) 3
loading
Tags: Tools
Jacob Saugmann
Asked On October 7, 2013 07:57 AM

Hi again :-)

Now im having trouble with the tree view

I would like to use a List of a custom class and display it as a Tree View

My custom class has these properties

I would like to use the ModelType as the parent. - these types exist


I just cant see how to do it.
The ModelType is the id and the name i would like so use in the treeview.
i tried like so;
Controller:

And view:

And then i get a ArgumentException  (ArgumentType dosen't match)
I can't find any description in the documentation, the closest i found is on this URL:
http://help.syncfusion.com/ug/asp.net%20mvc/tools/documents/objectdatabinding.htm

Is it possible to use a List<CustomClass> ad the datasource in a TreeView?

Best

- Jacob


Sunil Prabakar C [Syncfusion]
Replied On October 10, 2013 09:09 AM

Hi Jacob,

 

Thanks for using Syncfusion products.

 

We can  use the List<CustomClass> as a datasource for Treeview control. The reason for the “Argument Exception” issue in your application is, the parent id of Treeviewfield is in the type of Object of your custom class. We must declare the parent id of the Treeviewfiled in the type of String/Integer. Please refer the code snippet.

 

<Code>

 

[CS]

 

TreeViewFields fields = new TreeViewFields {

Id = "Modelid",

ParentId = "Regiseterid", //Must be in String/Integer

Text="Brand"

};

 

[CS]

 

</Code>

 

 

For your convenience we have prepared a simple sample to exhibit this behavior and it is available in the following link,

TreeView_113472.zip

Kindly let us know, if you have any other queries.

Regards,

Sunil Prabakar C


Jacob Saugmann
Replied On October 10, 2013 03:54 PM

Hi

Thanks for your reply,
i have now made a ModelTypeString in my class so it looks like this now:

Ive changed my code to look like the example but using ModelTypeString instead of registerid

Now i don't get an exception, but there is no treeview on the page
my view:

and here is the result in Internet explorer:
While debugging i get these


IE

My list has 10 items
When i run your sample everything works, ive looked at the _layout file web.config but everything seems to match your example.

Best

Jacob



Sunil Prabakar C [Syncfusion]
Replied On October 17, 2013 06:38 AM

Hi Jacob,

 

Thanks for your update.

 

We suspect this issue is due to referring higher version of Jquery in your application. Our Syncfusion controls are tested till Jquery version 1.8 and works fine without any issues till this specific version. If you are referring higher version of Jquery, the control cannot render properly. To overcome this reported issue, you can use "Jquery-Migrate" script file along with higher version Jquery. Please refer the below given code snippet which explains this behavior.

 

<Code>

 

[_Layout.CSHTML]

 

<script src="~/Scripts/jquery-2.0.1.min.js"></script>

<script src="~/Scripts/jquery-migrate-1.2.1.js"></script>

 

 

<Code>

 

Note: jquery-migrate.js is kept in script folder.

 

We have also prepared a simple sample to showcase this behavior and the sample can be downloaded from the link given below.

 

www.syncfusion.com/downloads/support/directtrac/109432/TreeView_113472-307278323.zip

 

Kindly let us know if you have any other queries.

 

Regards

Sunil Prabakar C


CONFIRMATION

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.

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.

;