Ady96
Ady96

Reputation: 716

Adding the data to the specific columns and rows using Vaadin 7.8.4 (Java)

How I can include the data to the grid at the specific row and column? When i want add the data e.g to the blue cell? Thank you! enter image description here

Upvotes: 2

Views: 883

Answers (1)

Shirkam
Shirkam

Reputation: 754

In Vaadin -> Grid, all rows are identified by an unique ID, which depends on which kind of container you used to store that data.

Let's have an example on IndexedContainer. In this container, you can specify the row ID when you do addItem([Object itemId]). This id is what you are gonna use to write in a particular cell. To write in a particular column, you can obtain an itemProperty which is where that cell value is stored. Using that IndexedContainer example, code will look like this:

IndexedContainer container = new IndexedContainer();
//Add container properties like "name"
//container.addContainerProperty("name", String.class,"");
//From IndexedContainer docs: addContainerProperty(Object propertyId, Class type, Object defaultValue)
container.addItem(1);
Item item = container.getItem(1);
item.getItemProperty("name").setValue(someValue);

It will allow you to write on cells. If instead an Indexed, you are using a BeanItemContainer, per example, the object inserted will be used as data and ID.

EDIT: To set any container as the data source of a grid, write grid.setContainerDataSource(containerName);

Upvotes: 1

Related Questions