Hierarchy using varchar

8 posts, 1 answers
  1. Matt
    Matt avatar
    58 posts
    Member since:
    Jun 2009

    Posted 21 Sep 2009 Link to this post

    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

     

  2. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 23 Sep 2009 Link to this post

    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.
  3. Matt
    Matt avatar
    58 posts
    Member since:
    Jun 2009

    Posted 24 Sep 2009 Link to this post

    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

  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 24 Sep 2009 Link to this post

    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.
  5. Matt
    Matt avatar
    58 posts
    Member since:
    Jun 2009

    Posted 24 Sep 2009 Link to this post

    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
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 26 Sep 2009 Link to this post

    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.
  7. Matt
    Matt avatar
    58 posts
    Member since:
    Jun 2009

    Posted 27 Sep 2009 Link to this post

    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 :(
  8. Matt
    Matt avatar
    58 posts
    Member since:
    Jun 2009

    Posted 27 Sep 2009 Link to this post

    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

Back to Top