Add pagination from code

I am displaying data from a table in blank screen using datagrid. The data is not linked with any entity
So how can i add pagination component here.
I have the total rows count current page number and current page element count any time

I used attached code

pagination code

Hello!

I tried to create the simplePagination for the ParentTable this way, and it seemed to work:

        SimplePagination simplePagination = uiComponents.create(SimplePagination.class);

        PaginationDataBinder dataSourceProvider = getApplicationContext()
                .getBean(PaginationContainerBinder.class, parentsDc);
        dataSourceProvider.setFirstResult(0);
        dataSourceProvider.setMaxResults(500);

        simplePagination.setDataBinder(dataSourceProvider);
        parentsTable.setPagination(simplePagination);

Try the same.

Regards,
Dmitriy