SimplePagination programatically change

There is a TextField in which you enter the number of displayed items on one page of the DataGrid. I tried to do this by setting an event listener on the TextField like this:

textField.addValueChangeListener(e -> {
            simplePagination.setItemsPerPageOptions(new ArrayList<Integer>() {{
                add(e.getValue());
            }});
            simplePagination.setItemsPerPageDefaultValue(e.getValue()); 
            dataGrid.execute();
        });

But the SimplePagination didn`t respond to this code. How to do it right?

Hello!

itemsPerPageOptions and itemsPerPageDefaultValue work only at component initialization time if itemsPerPageVisible is set to true.

If you just need to change page items without showing available items in SimplePagination, set max result directly to a loader:

textField.addValueChangeListener(e -> {
    myEntitiesDl.setMaxResults(e.getValue());
    ordersDl.load();
});
1 Like