Index of line grid selected

HI everybody. I don’t find how to get the index of the selected line in a grid (v24). How can I have this information ? Thank you in advance.

I looked in the API but could not find a way to get this. I wonder if that’s because the index of the selected row doesn’t matter since you would normally have the following and just perform the desired action as needed:
grid.asSingleSelect().addValueChangeListener(e → …);

Perhaps state what you’re trying to do with the index and maybe there is a different approach to take. Just a thought.

I think he wants a virtual column showing the numbers for each row

If your grid is not lazy loaded then you can retrieve the index in the list view/ data provider. If it’s lazy loaded then the index is not reliable.

Damn. My grid is a lazy loaded … I’ve asked this question because to select the line by programmation I’ve used the method “grid.select(item)” but

I have an error on my web interface

image.png

On my project I have a view with a list and then when i click on an item I have an other view with the item detail.

After update the detail I want to display the grid with the item selected, and that why I need to use “grid.select(item)”

Is someone know how to solve this error on method “do.selection” ?

Normally you can do this: organizationGrid.select(dataView.getItem(0));
The Javascript error shouldn’t happen, maybe there is a ticket about this or you can try to reproduce it in a sample project.

(The performance are probably really bad if the index is like 400000)

https://cookbook.vaadin.com/grid-scroll-tracking?i=82

I’ve found the origin of my error, I 've used the link below to remember scroll position. When I don’t use it I have no error. But it’s not finally a problem because the scroll tracking work fine. Thank you for your help