Table with row numbers its possible?

Hi guys! Its possible add the static column to Table Object with rows number?

-Greetings,
Pblo.

You can do it using Generator Column. To start with try some thing like following -

[code]
table.addGeneratedColumn(“Sl No”, new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            //Increment a counter
            // TODO Add criteria to check if a value is already  generated.
            return new Label(""+inc++);
        }
    });

[/code] - Krishna

Hi Krishna!

Its true! but this columns its reorder :/. I neet to static column. Its possible this?

Tnks!

You mean to say that you want to specify the order? If so you can set the order of columns by using visibleColumns api of table.

Say, you want the order of column in this specific order like - Sl No, Col1, Col2, Col3 then you can achieve it using the following API - table.setVisibleColumns("Sl No","Col1", "Col2", "Col3"); where Col1, Col2 & Col3 are Column IDs

-Krishna

I think I not explain, I need a static column. In Vaadin Table, when header column is clicked, the values are re order in asc or desc, then if I add a column how you say me, no works how I want. I need a static column with rows number, that not are re ordered when the header its clicked. Put a Example: sheet of Excel.

Tnks!
-Pblo

Hello Pablo,

In case you are using IndexedContainer as Table backend, you could try to set the row header mode as follows:

table.setRowHeaderMode(Table.RowHeaderMode.INDEX);

In basic scenario, this should produce the line numbering for you.

Best regards,
Matti

Hey Matty!
Thanks! just what I needed!

Regards,

  • Pblo