Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add button in a Grid in Vaadin

Tags:

vaadin

vaadin7

Hi Im try to add button in a grid in vaadin but it print the reference on button object.

Grid statementEnquiriesList = new Grid();
statementEnquiriesList.addColumn("", Button.class);
        statementEnquiriesList.addColumn("DATE/TIME", String.class);
        statementEnquiriesList.addColumn("TRANSACTION ID", String.class);
        statementEnquiriesList.addColumn("FROM", String.class);

// historyList is an array object
for (int i = 0; i < historyList.size(); i++)
{
    HistoryList recordObj = historyList.get(i);
    Button addBtn = new Button();
    addBtn.setCaption("Add");
    statementEnquiriesList.addRow(addBtn , recordObj.getDate(), recordObj.getTransactionId(), recordObj.getFrom());
}

how can i print "Add" caption on this

enter image description here

like image 213
herman shafiq Avatar asked Mar 29 '16 08:03

herman shafiq


People also ask

How do I add a button in grid vaadin?

Vaadin 8.1 - Components in Grid. Vaadin 8.1 now has a built-in ComponentRenderer for displaying buttons or other components including your own custom components in a Grid. See first item "Components in Grid" on What's New page. Example: Add a label to a grid.

How do you add a button on the grid?

To add these ButtonFields, click on the Edit Columns link from the GridView's smart tag, select the ButtonField field type from the list in the upper left and click the Add button. Move the two ButtonFields so that they appear as the first two GridView fields.


1 Answers

Vaadin 8.1 - Components in Grid

Vaadin 8.1 now has a built-in ComponentRenderer for displaying buttons or other components including your own custom components in a Grid.

See first item "Components in Grid" on What's New page.

Example: Add a label to a grid.

grid.addColumn(
    person -> new Label( person.getFullName() ) ,
    new ComponentRenderer()
).setCaption( "Full Name" ) 
like image 167
Basil Bourque Avatar answered Oct 03 '22 14:10

Basil Bourque