Dynamic DataGrid pagination

How can I dynamically change the number of displayed items on a page in a DataGrid? I tried using

simplePagination.setItemsPerPageOptions(List.of(event.getValue()));
simplePagination.setItemsPerPageDefaultValue(event.getValue());

But it don’t change the number of rows per page.