Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom pagination proposal #327

Merged
merged 3 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 41 additions & 30 deletions src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@
</slot>
</div>
<div class="vgt-inner-wrap" :class="{'is-loading': isTableLoading}">
<vgt-pagination
<slot
v-if="paginate && paginateOnTop"
ref="paginationTop"
@page-changed="pageChanged"
@per-page-changed="perPageChanged"
:perPage="perPage"
:rtl="rtl"
:total="totalRows || totalRowCount"
:nextText="nextText"
:prevText="prevText"
:rowsPerPageText="rowsPerPageText"
:customRowsPerPageDropdown="customRowsPerPageDropdown"
:paginateDropdownAllowAll="paginateDropdownAllowAll"
:ofText="ofText"
:allText="allText"></vgt-pagination>

name="pagination-top"
:pageChanged="pageChanged"
:perPageChanged="perPageChanged"
:total="totalRows || totalRowCount">
<vgt-pagination
ref="paginationTop"
@page-changed="pageChanged"
@per-page-changed="perPageChanged"
:perPage="perPage"
:rtl="rtl"
:total="totalRows || totalRowCount"
:nextText="nextText"
:prevText="prevText"
:rowsPerPageText="rowsPerPageText"
:customRowsPerPageDropdown="customRowsPerPageDropdown"
:paginateDropdownAllowAll="paginateDropdownAllowAll"
:ofText="ofText"
:allText="allText"></vgt-pagination>
</slot>
<vgt-global-search
@on-keyup="searchTableOnKeyUp"
@on-enter="searchTableOnEnter"
Expand Down Expand Up @@ -166,22 +171,28 @@
</tbody>
</table>
</div>
<vgt-pagination
<slot
v-if="paginate && paginateOnBottom"
ref="paginationBottom"
@page-changed="pageChanged"
@per-page-changed="perPageChanged"
:perPage="perPage"
:rtl="rtl"
:total="totalRows || totalRowCount"
:nextText="nextText"
:prevText="prevText"
:rowsPerPageText="rowsPerPageText"
:customRowsPerPageDropdown="customRowsPerPageDropdown"
:paginateDropdownAllowAll="paginateDropdownAllowAll"
:ofText="ofText"
:allText="allText"
></vgt-pagination>
name="pagination-bottom"
:pageChanged="pageChanged"
:perPageChanged="perPageChanged"
:total="totalRows || totalRowCount">
<vgt-pagination
ref="paginationBottom"
@page-changed="pageChanged"
@per-page-changed="perPageChanged"
:perPage="perPage"
:rtl="rtl"
:total="totalRows || totalRowCount"
:nextText="nextText"
:prevText="prevText"
:rowsPerPageText="rowsPerPageText"
:customRowsPerPageDropdown="customRowsPerPageDropdown"
:paginateDropdownAllowAll="paginateDropdownAllowAll"
:ofText="ofText"
:allText="allText"
></vgt-pagination>
</slot>
</div>
</div>
</template>
Expand Down
28 changes: 27 additions & 1 deletion vp-docs/guide/advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,30 @@ Sometimes you might want to customize column headers. You can do that in the fol
</span>
</template>
</vue-good-table>
```
```

## Custom pagination

Sometimes you might want to customize the pagination. You can do that in the following way:
```html
<vue-good-table
:columns="columns"
:rows="rows"
:pagination-options="{enabled: true}">
<template slot="pagination-bottom" slot-scope="props">
<custom-pagination
:total="props.total"
:pageChanged="props.pageChanged"
:perPageChanged="props.perPageChanged">
</custom-pagination>
</template>
</vue-good-table>
```

::: tip NOTE
You will have to implement your own pagination system:

* The total number of rows can be accessed via `props.total`
* The function to call when the current page has changed can be accessed via `props.pageChanged`.
* The function to call when the per page value has changed can be accessed via `props.perPageChanged` .
:::