简体   繁体   中英

How to get first-child sibling without using detailinit function in Kendo Hierarchy grid?

I used Hierarchy grid to my web page. In hereI used print Button on each row to print row data. But now I can`t get first-child data by using this code .

    var dataItem =  $(e.target).closest('td').siblings(':first-child').text();

How can I get first column data.

If you wamt tp access the master record from the details Grid, the easies way would be keeping information about the parent (for example the id ) and then use it.

Said so, if you want to use HTML - DOM for getting it, what you have to do is:

First, find the row that contains the Details Grid in the Master Grid

var row = $(e.target).closest(".k-detail-row");

Next, find the previous sibling (the row that contains the master record)

var master = myRow.prev();

And now you can get either the data in the model or the text from the Grid but you should remember that the first cell in the master row is the handler for collapsing / expanding the details

var item = grid.dataItem(master);
var text = master.find("td:nth(1)");

A running example here : http://jsfiddle.net/OnaBai/Wzr46/2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM