Cannot select table item

Hello, I cannot select a table row.

The code:


tbl.setContainerDataSource(c);
tb.setSizeFull();
tbl.setColumnCollapsingAllowed(true);
tbl.setColumnReorderingAllowed(true);
tbl.setSelectable(true);
tbl.setVisibleColumns(MASCHERA);
tbl.setColumnHeaders(COLUMN_HEADERS);
tbl.setNullSelectionAllowed(false);

tbl.getItemIds(); //returns all ids in the table correctly
tbl.setValue("33"); // 33 is a correct id, but it does not work.
tbl.setValue(tbl.getItem("33")) //item returned is null

The same behaviour with tbls.select(“id”).

Any help??

Bonjour,
what kind of Container is c ?

Gilles

sorry, it is a SQLContainer.

I have a window above the table and when I close that window I want to select a row in the table.
The id of the choiched row is calculated in the window.

If I do table.setValue(table.ferstItemIt()) it works

Bonjour,
are you sure that the itemid is of type String ?
you tried
`tbl.setValue(“33”);

maybe it is tbl.setValue(33);

What is the type of the id column in your database table ?

Gilles

Yes, I have printed the type of itemid and it is a String.

Please use setImmediate() method for components when you change their state programmatically.

tbl.setImmediate(true);

should work.

I tried, it doesn’t work.

Because you should use select() method, not setValue():
Check here.

The item with passed id is highlighted in my experiments.

I think the problem is that I do setValue() from a popup window.

Did you use select() method?

Both select() and setValue()…

Id of an Item in SQLContainer is not of type String. It’s type of com.vaadin.data.util.sqlcontainer.RowId. select(“33”) doesn’t compare well with RowId. SQLContainer implements Container.Indexed so you can get an Item at index by calling getIdByIndex()

But I don’t know the index of inserted item. I have the id.