How do I access Table-components selected row's values.

I have Table with few headers and few items as rows.
How do I access current selected row’s value in example second header.

Lets say I have generated header with:
.addContainerProperty(“email”,String.class,“”,“Email”,null,Table.ALIGN_LEFT)
and I want to get selected rows value email.

A quick answer for the case you described:


Object rowId = table.getValue(); // get the selected rows id
String email = (String)table.getContainerProperty(rowId,"Email").getValue();

Ok, really: you should check for null selection also. :slight_smile:

I got it worked in my scebnario the following way

Suppose you have a table object and you’re populating the data in table using bean container as shown below

Table table = new Table() ;

BeanItemContainer container = new BeanItemContainer(SomeBean.class);

container.addAll(listOfSomeBeanObjects);

table.setContainerDataSource(container);


//Returns the row selected on table
Object itemId = table .getValue();

//get the index of the item selected
int index = container.indexOfId(itemId);

Hello,
I got similar problem at first, but I manage to solved it. Now I’m wondering at something else.
So, after selecting item in table I want to copy that to new table in my sql base. To contains data I’m using beanscontainer. In my main table I have listener in which one I got index of item being selected. Now I’m looking to advise about how to put data in my second base. I need to simply update bean into my sql?
Thanks!

Object currentItemId = event.getItemId();

Object itemPropertyValue = table.getItem(currentItemId).getItemProperty(“propertyName”).getValue();

tx

i using mongodb ,the table propertyname are frequiently change based on collection, so how can i use this condition
Object currentItemId = event.getItemId();
Object itemPropertyValue = table.getItem(currentItemId).getItemProperty(“propertyName”).getValue();

i need to get entire row value when the row is selected .
what condition i have used ??