Search code examples
javavaadinvaadin-grid

Vaadin Grid numbering of the rows


I'm new to the vaadin. And I had a question how to create the numbering of lines in the grid using grid.addColumn(???).setHeader("#").


Solution

  • It would be easiest to do with TemplateRenderer this way

    grid.addColumn(TemplateRenderer.of("[[index]]")).setHeader("#")
    

    So then you would get index of the row in the column (which will not depend on Bean content, sorting etc.) There is more info about TempateRenderer in Vaadin Documentation