0

My table have a big query, so I want to make the user filter some fields before displaying the table data.

It's possible to make the table get the data only on the click of some button? Actually when I load my view the table already get the data, this is made by the PagedTable or the LazyBeanContainer(I'm using Lazy Container to paginate my table)?

3
  • @quinxorin Do you know Vaadin? Commented Jun 13, 2013 at 12:02
  • No, I unfortunately do not. Wait, java! Not javascript. Oops, misread the tag. Commented Jun 13, 2013 at 12:03
  • add a Button.ClickListener instead of loading data when loading the view Commented Jun 13, 2013 at 14:35

2 Answers 2

3

At first you can just init the Table

Table table = new Table()

You should then define a container for your table (I suggest you to use BeanItemContainer)

BeanItemContainer<YourObject> container = new BeanItemContainer<YourObject>(YourObject.class);

At last, you should fill the container in the Button.ClickListener

Button button = new Button("Button", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                table.setContainerDataSource(container);
            }
        });
Sign up to request clarification or add additional context in comments.

Comments

0

My solution was to set generated columns in the creation of my view:

String[] columns = new String[]{"id","myField"}

for(String col : columns) {
  table.addGeneratedColumn(col, new ColumnGenerator() {
    public Object generateCell(Table source, Object itemId, Object columnId) {
      return "";
    }
  });
}

This results in an empty table, but with columns and labels. Then in the button click, I set the container and remove the old columns:

for(String col : columns) {
  table.removeGeneratedColumn(col);
}
table.setContainerDataSource(myContainer);
...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.