gridjs icon indicating copy to clipboard operation
gridjs copied to clipboard

Add a new way to paginate

Open tomasweigenast opened this issue 5 years ago • 3 comments

This partially merges pagination in the core of the library by adding a new property to the Tabular class which is hasNextPage. The commit also introduces a new property to PaginationConfig:

type: PaginationType

which accepts to values:

export type PaginationType = "opaque-based" | "offset-based";

They are the two pagination types. offset-based is already provided by Gridjs natively and needs the total property in the server's one to work. opaque-based is the new one and it works by changing the property total by hasNextPage one. It has the same signature (hasNextPage: (data) => boolean).

By enabling opaque-based pagination using the type property, Gridjs will skip automatically renderPages and renderSummary since this pagination type, usually, relies on "next page tokens" and the pattern does not provide information about how many pages are left or the total count of entries in the server.

NOTE: opaque-based pagination is enabled by default.

The normal behavior of Gridjs pagination can be enabled by switching type to offset-based.

tomasweigenast avatar Dec 07 '20 19:12 tomasweigenast

@afshinm hey! check this out and tell me what do you think about it.

tomasweigenast avatar Dec 10 '20 23:12 tomasweigenast

Thanks @TomasWeg! I will take a look

afshinm avatar Dec 10 '20 23:12 afshinm

Sure, I will do it in a moment.

tomasweigenast avatar Dec 14 '20 21:12 tomasweigenast