简体   繁体   中英

Kendo Grid clicked row count

How can I exclude group names while calculating the clicked row count in a Kendo grid?

I have 10 data in a grid under 3 groups. If I click on the last row it returns count as 12 . I'm using the below code.

var rowIdx = $("tr", grid.tbody).index($(this).closest('tr'));

Thanks in advance

What are you trying to accomplish? There might be a different way to go about it. For example, $('#gridName').data('kendoGrid').dataSource.total() would give you 10.

Update

This code will get you the selected row number in the case only one row is selected:

let selectedRows = $('#gridName').data('kendoGrid').select()
selectedRows[0].rowIndex

The Below code works.

    var grid = $("#daGrid").data("kendoGrid");
    var dataRows = grid.items();
    var uid = grid.select()[0].dataset.uid
    var documentItems = grid.dataSource.getByUid(uid);
    var tr = $("[data-uid='" + uid + "']", grid.tbody);
    var rowIndex = dataRows.index(grid.select());

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