Skip to content

Commit

Permalink
* dtable: refactor pager callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Oct 16, 2024
1 parent d3ec426 commit 93f43bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/dtable/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ onPageUpdate(() => {
recPerPage: 10,
linkCreator: '#?page={page}&recPerPage={recPerPage}',
},
localPager: true,
footer: ['checkbox', 'divider', 'checkedInfo', 'divider', 'flex', 'pager'],
});
console.log('DataTable', datatable);
Expand Down
13 changes: 2 additions & 11 deletions lib/dtable/src/plugins/pager/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,11 @@ const pagerPlugin: DTablePlugin<DTablePagerTypes> = {
});
}
if (this.options.localPager) {
footPager.onChangePageSize = (info) => {
footPager.onChangePageInfo = (newPager) => {
this.update({
dirtyType: 'layout',
state: (prevState) => {
const pager = {...(prevState as unknown as DTablePagerTypes['state']).pager, recPerPage: info.recPerPage};
return {pager};
},
});
};
footPager.onGoToPage = (info) => {
this.update({
dirtyType: 'layout',
state: (prevState) => {
const pager = {...(prevState as unknown as DTablePagerTypes['state']).pager, page: info.page};
const pager = {...(prevState as unknown as DTablePagerTypes['state']).pager, ...newPager};
return {pager};
},
});
Expand Down

0 comments on commit 93f43bf

Please sign in to comment.