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

Tree View and custom List as DataSource

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


3 Replies

SP Sunil Prabakar C Syncfusion Team October 10, 2013 01:09 PM UTC

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



JS Jacob Saugmann October 10, 2013 07:54 PM UTC

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




SP Sunil Prabakar C Syncfusion Team October 17, 2013 10:38 AM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon