Accessing the dataItem

3 posts, 0 answers
  1. mgs
    mgs avatar
    163 posts
    Member since:
    Jan 2011

    Posted 11 Mar 2013 Link to this post

    The TreeView has a method "dataItem" for accessing a model corresponding to a node. As the only argument it takes the HTML element (or it's jQuery selector or jQuery object).

    Which HTML can or should be given to the method?

    When looking at the generated HTML, there is roughly the following structure.
    <div data-role="treeview">
       <ul class="k-group k-treeview-lines">
          <li class="k-item k-first">
             <div class="k-top">
                <span class="k-icon"></span>
                <span class="k-in">text</span>
    When trying the "li", "div", "first span", "second span", it seems as if all were accepted by "dataItem". Is this correct? Is this always so with all widgets?

    Michael G. Schneider
  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 11 Mar 2013 Link to this post

    Hi Michael,

    Yes, the TreeView's dataItem method accepts the <li> element or any of its descendants. This is because the method internally finds the <li> with the closest() jQuery method.

    Since the HTML output of each widget is different, I cannot say that the mechanism is identical in all cases. Although we try to make the API more flexible with regard to such scenarios, I advise you to refer to our documentation and see the examples for the recommended usage of each method.

    Greetings,
    Dimo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. mgs
    mgs avatar
    163 posts
    Member since:
    Jan 2011

    Posted 11 Mar 2013 Link to this post

    Hello Dimo.

    thanks a lot for the answer.

    Michael G. Schneider

Back to Top