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

How to find the selected row index in Hierarchical Grid

1 Answer 829 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vijay
Top achievements
Rank 1
Vijay asked on 30 Apr 2014, 01:34 PM
Hi,
    Today we have a new issue where e.masterRow[0].rowIndex does not give the correct row index.The scenario is like this.

We have a hierarhical grid which is prepopulated with 9 rows. I add a new row to this grid. when I click on the second row the child grid is populated.
I get the rowindex correctly. Now when I click on any row below the secong row the rowindex given by e.masterRow[0].rowIndex  would be incremented by 1. Is there any other method to get the row index of the currently selected row which needs to be expanded.


Regards,
Vijay

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 02 May 2014, 07:17 AM
Hello Vijay,

The rowIndex property won't work in this case because the detail row is inserted in a row itself which affects the row number.

Use the following instead:

var index = e.masterRow.index(".k-master-row");

Here is a live demo: http://trykendoui.telerik.com/@korchev/Efom

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Mark
Top achievements
Rank 1
commented on 07 Sep 2022, 03:20 PM

I believe this answer can cause unexpected issues.

As .index() without any arguments will look at the Siblings only. But once the argument has been added it will traverse the whole collection. So if you have more than one grid on the page this will give you the wrong index.

e.masterRow.prevAll(".k-master-row").length
Seems to be working instead.

Georgi Denchev
Telerik team
commented on 09 Sep 2022, 12:00 PM

Hi, Mark,

Thank you for sharing your insights and an alternative approach!

Best Regards,

Georgi

Tags
Grid
Asked by
Vijay
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or