DataGrid: How can i back to the first page on refresh?

Hi there,

i have the next problem:

my app contains in the same page filter+datagrid. when i go to 2+ page and use the filter doing datasource.refresh(), the datagrid still on the same page (2+) when this just has 1 page

public void onRefreshButtonClick() {
    transactionDs.refresh();
    transactionDataGrid.scrollToStart();
}

im trying to restart the datagrid to the page 1 but dont see nothing like datagrid.setPage(0) and scrollToStart() dont set the page. How can i go to the first page of the datagrid?.

Thanks for the help,
-Pedro

1 Like

Hi,

In order to go to the first page, cast your datasource to CollectionDatasource.SupportsPaging and call setFirstResult(0)

((CollectionDatasource.SupportsPaging) transactionDs).setFirstResult(0);
transactionDs.refresh();

Regards,
Gleb

1 Like

Hi Gleb,

((CollectionDatasource.SupportsPaging) transactionDs).setFirstResult(0);

Works propertly, thanks so much.

Regards,
Pedro.

1 Like