I would like to display the rowindex in a grid column but starting with 1 not with 0.
* The following built-in template variables can be bound to inside the column templates:
* - `[[index]
]`: Number representing the row index
In the file org\webjars\bowergithub\vaadin\vaadin-grid\5.0.4\vaadin-grid-5.0.4.jar!\META-INF\resources\webjars\vaadin-grid\src\vaadin-grid.html I found the updateItem(row, item) method which sets the cells’s index property to row.index and I can use this in java code like myJavaGrid.addColumn(TemplateRenderer.of("[[index] ]")).setHeader("#")
Kaspar: I don’t think this will work.
A DataProvider can be queried with a subset (offset, limit) of all items. Using that result and calculating the index from it may be wrong.
You’d better cache all sorted items and calculate the index from that list.
I see what you mean. I did indeed not think of large datasets. Thanks for the find, I’m working on it.
And yes I have seen that issue for a long time and have voted too. But nowhere is described currently how to do a 1-based index without touching the polymer stuff. I know my way of allowing such a column is overkill, but at least it works. Sometimes we have to overlook some inefficiencies as long as we are able to deliver.
Sometimes we have to overlook some inefficiencies as long as we are able to deliver.
Of course. Me too, but my solution differs (sort listener, fetching all, saving index in a map instead of slow indexOf).
I like the idea of Vaadin, being a framework in which 99% of all use cases can be solved instantly without a hassle. And we can of course work around bugs and inefficiencies.
I said overkill because I think the learning curve for such a simple feature is too steep. And the use case is not a real corner case.