GridView
View to display grid data
The data model of a grid, FiniteGrid, is a two-dimensional vector of integer values. The data model is buffered; you initialize an update with initwrite() and flush the buffer with commit(). The get() method reads from the "old" buffer and set() writes go to the "new" buffer. The view, GridView, shows zeros as white squares and ones as black squares.
Sample code
package org.vaadin.gridview; import org.vaadin.gridview.data.FiniteGrid; import com.vaadin.Application; import com.vaadin.ui.*; import com.vaadin.ui.Button.ClickEvent; public class GridViewApplication extends Application { @Override public void init() { Window mainWindow = new Window("GridView Demo"); setMainWindow(mainWindow); Label label = new Label("This example demonstrates the use of the GridView."); mainWindow.addComponent(label); // Create the data model. final FiniteGrid grid = new FiniteGrid (100, 100); grid.initData(); // Put some content in the data model. putSomeDataInTheGrid(grid); // Create a view and bind it to the data model. final GridView view = new GridView(grid); view.setWidth("400px"); view.setHeight("400px"); mainWindow.addComponent(view); // Updates the data. Button update = new Button("Update"); update.addListener(new Button.ClickListener() { private static final long serialVersionUID = -6967557302246176385L; public void buttonClick(ClickEvent event) { putSomeDataInTheGrid(grid); view.update(true); } }); mainWindow.addComponent(update); } void putSomeDataInTheGrid(FiniteGrid grid) { grid.initWrite(); for (int i=0; i<grid.rows(); i++) for (int j=0; j<grid.cols(); j++) grid.set(i, j, (int) Math.round(Math.random()*2)); grid.commit(); } }
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
- Released
- 2010-01-22
- Maturity
- EXPERIMENTAL
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 6.2+
- Browser
- Firefox
GridView - Vaadin Add-on Directory
View to display grid dataThe data model of a grid, FiniteGrid, is a two-dimensional vector of integer values. The data model is buffered; you initialize an update with initwrite() and flush the buffer with commit(). The get() method reads from the "old" buffer and set() writes go to the "new" buffer. The view, GridView, shows zeros as white squares and ones as black squares.