Created
April 2, 2015 06:06
-
-
Save KrishnaKotari/4d043616df2b3378f4f1 to your computer and use it in GitHub Desktop.
All Code related to Part 1 of my series on Vaadin Grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This doesn't give you caption | |
Grid grid = new Grid(); | |
// This creates a caption and can be seen on the top left corner of the grid | |
Grid grid = new Grid("Basic"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add few columns followed by Data | |
grid.addColumn("name", String.class); | |
grid.addColumn("city", String.class); | |
grid.addColumn("pincode", String.class) | |
.... | |
// Add some data rows | |
grid.addRow("Krishna", "Bangalore","560085"); | |
grid.addRow("Anirudh", "Sindhanur","584128"); | |
grid.addRow("Harin", "Bangalore","560027"); | |
grid.addRow("Anil", "Vijayawada","520007"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Initialize the container | |
BeanItemContainer<Person> container = new BeanItemContainer<Person>(Person.class); | |
container.add(new Person(1, "Krishna","Bangalore","560085"); | |
container.add(new Person(2, "Anirudh", "Sindhanur","584128"); | |
container.add(new Person(3, "Harin", "Bangalore","560027"); | |
container.add(new Person(4, "Anil", "Vijayawada","520007"); | |
//Add the container to the datasource | |
grid.setContainerDataSource(container); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grid.addSelectionListener(new SelectionListener() { | |
@Override | |
public void select(SelectionEvent event) { | |
Set<Object> itemIDs = event.getSelected(); | |
//TODO do something with the items | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From the above example, I wish to hide the PersonID, so I do the following | |
grid.removeColumn("personID"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From the above Person example | |
grid.setColumnOrder("personName", "city", "pincode"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Again from the Person example | |
// Get the Column object associated with the property | |
Column city = grid.getColumn("city"); | |
// Set the Column Caption | |
city.setHeaderCaption("Person City"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment