DataTable problem when rowsperpage is equal to no of records in the table

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DataTable problem when rowsperpage is equal to no of records in the table

venkataprasad.n
HI,

I am working on using DataTable and I could display all the records. As I wanted to have pagination, I have set the RowsPerPage = 3, but the actual no of records in my table are 10. This is working very perfectly and I could see the pagination links also.

Now I have tried creating datatable instance with rowsperpage=10, in this case I dont see any pagination tool bar.

My actual requirement is I need to have a dropdown in the bottom navigatioon bar, where the user have the choice to select the no of records per page....Suppose, if my table having 10 record.... the dropdown is having values 2,4,6,8,10. When i select 2,4,6,8 everything is working perfectly and I can see the toolbar with pagination. But when I select 10, I dont see the navigation bar at all. what might be the reason?
Reply | Threaded
Open this post in threaded view
|

Re: DataTable problem when rowsperpage is equal to no of records in the table

Gabriel Landon
Please have a look at the NavigationToolbar class.
You will see in the code that the toolbar is hidden when there are only one page:
        ....
       /** {@inheritDoc} */
        @Override
        protected void onBeforeRender()
        {
                setVisible(getTable().getPageCount() > 1);
                super.onBeforeRender();
        }
        ....

You can override this behavior if you want.

Example :
DataTable table = new DataTable("datatable", columns, new UserProvider(), 10);
table.addBottomToolbar(new NavigationToolbar(table) {
        @Override
        protected void onBeforeRender() {
                super.onBeforeRender();
        }
});

regards,

Gabriel.