Reputation: 479
Can anyone point me to an example of using the Pagination extension of dgrid with a dgrid? This could be a reference link or a simple example you type up. I've defined it in my code, used it with an OnDemandGrid where it is added to the declare mixin for my custom grid. I see arrows for page navigation, I see the page size setting menu, but my specification of rowsPerPage: 3 does nothing. I still see my 7 sample records.
I'm using a modified Cache (data object store) that wraps a JsonRest and Memory store for my dgrid.
Upvotes: 1
Views: 7058
Reputation: 27231
The best examples of DGrid and its extensions can be found in the test folder of the DGrid project. They can be found here:
Specifically the Paginations Tests can be found:
To run them:
Upvotes: 0
Reputation: 7852
I think the issue is that you can't use OnDemandGrid
with pagination since the OnDemandGrid
has it's own internal virtual paging logic. From the dgrid extensions wiki:
In contrast to the OnDemandList and OnDemandGrid modules, the Pagination extension implements classic discrete paging controls. It displays a certain number of results at a given time, and provides a footer area with controls to switch between pages.
Note: the Pagination extension should be mixed into List or Grid, not one of the OnDemand constructors, since those contain their own virtual scrolling logic. Internally, Pagination inherits from the same _StoreMixin module inherited by the OnDemand prototypes for common integration with dojo/store.
What you want to do instead is mixin Pagination
into a plain Grid
. The Pagination Mixin includes the properties you're interested in such as number of rows. The Paginator extension handles talking to the provided store for retrieving and rendering the set of rows to display. A define
for a class like that might look like:
define(['dojo/_base/declare','dgrid/Grid', 'dgrid/extensions/Pagination'],function(declare,Grid,Pagination){
return declare('mine.PaginatedGrid',[Grid,Pagination],{
//various default you can set
pagingLinks: false,
pagingTextBox: true,
firstLastArrows: true,
minRowsPerPage: 5,
rowsPerPage: 5,
pageSizeOptions: [5, 10, 15, 25, 50, 100]
});
});
Upvotes: 3