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

Hierarchy using varchar

7 Answers 60 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 21 Sep 2009, 12:58 PM
Hi,

Quick question, can I use fields of varchar as seeds for an auto generated tree hierarchy, such as -

RadTreeView1.DataFieldID =

"pagename";

 

RadTreeView1.DataFieldParentID =

"parentpagename";

 

RadTreeView1.DataTextField =

"pagename";

 

RadTreeView1.DataValueField =

"pagename";

Thanks
Matt

 

7 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 23 Sep 2009, 01:54 PM
Hi Matthew Waring,

I tested this with nvarchar and it worked fine.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matt
Top achievements
Rank 1
answered on 24 Sep 2009, 08:36 AM
Hi,

Could you please show me your test case, I must be doing something wrong as I cannot get it render even with a restricted basic data set with 1 parent and 9 child nodes! as follows -

Data (ParentPagename/Pagename) in custom object

:0-9.htm
0-9.htm:0-910.htm
0-9.htm:0-92.htm
0-9.htm:0-93.htm
0-9.htm:0-94.htm
0-9.htm:0-95.htm
0-9.htm:0-96.htm
0-9.htm:0-97.htm
0-9.htm:0-98.htm
0-9.htm:0-99.htm

Thanks
Matt

0
Veselin Vasilev
Telerik team
answered on 24 Sep 2009, 03:17 PM
Hi Matthew Waring,

Please find attached a sample project. You will see that the database fields are of type NVARCHAR

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matt
Top achievements
Rank 1
answered on 24 Sep 2009, 05:13 PM
Thanks Veselin for your help,

To clarify, what you are saying is the database field type can be varchar BUT the field contents must be castable to an integer?

My parent/node fields are all unique keys and do form a hierarchy but telerik does not support this alternative scenario.

Thanks
Matt
0
Veselin Vasilev
Telerik team
answered on 26 Sep 2009, 08:45 AM
Hello Matthew Waring,

Actually it should work.
Please change the values in the idResource and idResourceParent in the Tree table of the project I sent you to strings - the tree hierarchy will work.

Best wishes,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matt
Top achievements
Rank 1
answered on 27 Sep 2009, 07:40 PM
Thanks veselin,

Yes that does work, now I just have to work out why its not working for my collection of business objects as the datasource :(
0
Matt
Top achievements
Rank 1
answered on 27 Sep 2009, 08:57 PM
EDIT: I know now from the docs that business objects with certain child structures does not play well with some controls, so just beware of this and you should be fine

Hi Veselin,

The only way I could get it to work was to loop through my business objects and create a list of 

 

public class sitemaptreenode

 

 

{

 

public string Pagename { get; set; }

 

 

 

public string Parentpagename { get; set; }

 

 

 

public string URL { get; set; }

 

 

 

public string Displaytext { get; set; }

 

}

 


then bind this to the tree.  Something in my business object was tripping telerik up? no idea.

Also this in the docs was important -

- their DataFieldParentID property must be null if it is of nullable (e.g. int?) or reference (e.g. string) type.

example: 

ID ParentID

1   (null)

2   1 

- their DataFieldParentID property must return the default value if it is value type (e.g. 0 for int, Guid.Empty for Guid).

example:

ID ParentID

1   0

2   1

Thanks
Matt

Tags
TreeView
Asked by
Matt
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Matt
Top achievements
Rank 1
Share this question
or