Cannot get parent node text

4 posts, 1 answers
  1. Chanchal
    Chanchal avatar
    3 posts
    Member since:
    Jul 2013

    Posted 18 Jul 2014 Link to this post

    Hi, 

    I have a Kendo tree view with three levels. Please see the attached file MyTree.jpg.

    I have a leaf node's with text value "CHINA".  I am not able to get the leaf node's parent node text. Please see the attached file ChromeOutput.jpg. 

    Please advise why undefined is returned for below -

    treeview.text(treeview.parent(treeview.findByText("CHINA")))

    Regards, 
    Manoj



  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 18 Jul 2014 Link to this post

    Hello Manoj,

    I tried reproducing this problem in the following Dojo snippet, to no avail. Can you please adjust it so that it shows the problem?

    Regards,
    Alex Gyoshev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Chanchal
    Chanchal avatar
    3 posts
    Member since:
    Jul 2013

    Posted 18 Jul 2014 in reply to Alex Gyoshev Link to this post

    Hi Alex, 

    Thanks. 

    The problem is not simulating in the Dojo or Chrome console using the Dojo code. I am using razor view and C# to generate the tree. I am also attaching my tree view definition.

    Can you please advise any other way to get the parent node's text ?

    Regards,
    Manoj 












  5. Answer
    Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 21 Jul 2014 Link to this post

    Hello Chanchal,

    Remove the DataTextField line and the problem will be resolved.

    The problem in this scenario is that the DataTextField instructs the text method that the text is stored in the "Text" field. This can be true if the tree was loaded via AJAX; however, the TreeView is rendered from the server, so the datasource uses the default, lowercase-t "text" field. So, the text method returns undefined.

    Working sample is attached.

    Regards,
    Alex Gyoshev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready