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

Accessing the dataItem

2 Answers 116 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
mgs
Top achievements
Rank 1
mgs asked on 11 Mar 2013, 01:00 PM
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 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 11 Mar 2013, 02:19 PM
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!
0
mgs
Top achievements
Rank 1
answered on 11 Mar 2013, 04:04 PM
Hello Dimo.

thanks a lot for the answer.

Michael G. Schneider

Tags
TreeView
Asked by
mgs
Top achievements
Rank 1
Answers by
Dimo
Telerik team
mgs
Top achievements
Rank 1
Share this question
or