Skip to content

Commit d712581

Browse files
tsv2013tsv2013RomanTsukanov
authored
Disable Pagination: Add a pagination option and hide the page selector when pagination is disabled (#651)
* Disable Pagination: Add a pagination option and hide the page selector when pagination is disabled Fixes #320 * Rename the pagination toggle and add doccomments --------- Co-authored-by: tsv2013 <[email protected]> Co-authored-by: RomanTsukanov <[email protected]>
1 parent 11bbaff commit d712581

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

examples/custom_tabulator.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ var surveyAnalyticsTabulator = new SurveyAnalyticsTabulator.Tabulator(
1717
survey,
1818
normalizedData,
1919
{
20-
// useNamesAsTitles: true
21-
// columnMinWidth: 50
20+
// useNamesAsTitles: true,
21+
// columnMinWidth: 50,
22+
// pageSize: 10,
23+
// paginationEnabled: false
2224
}
2325
);
2426

src/tables/extensions/headerextensions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ TableExtensions.registerExtension({
9090
name: "showentries",
9191
visibleIndex: 3,
9292
render: function (table: Table): HTMLElement {
93+
if(table.options.paginationEnabled === false) {
94+
return DocumentHelper.createElement("div");
95+
}
9396
function getEntriesDropdown(table: Table): HTMLElement {
9497
const el = <HTMLSelectElement>DocumentHelper.createElement("select");
9598
var optionsValues = table.paginationSizeSelector || ["1", "5", "10", "25", "50", "75", "100"];

src/tables/table.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,22 @@ export interface ITableOptions {
4444
displayValue: any,
4545
}) => void;
4646

47+
/**
48+
* Specifies the number of data items to load and display per page. Applies only if `paginationEnabled` is `true`.
49+
*
50+
* Default value: 10
51+
* @see paginationEnabled
52+
*/
4753
pageSize?: number;
54+
/**
55+
* Specifies whether the dataset is split into pages.
56+
*
57+
* Default value: `true`
58+
*
59+
* > Pagination cannot be disabled if the dataset is loaded from a server (that is, if the second parameter passed to the `Tabulator` constructor is a function).
60+
* @see pageSize
61+
*/
62+
paginationEnabled?: boolean;
4863
}
4964

5065
export type TabulatorFilter = { field: string, type: string, value: any };

src/tables/tabulator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ export class Tabulator extends Table {
151151
{
152152
data,
153153
layout: "fitColumns",
154-
pagination: "local",
154+
pagination: this.options.paginationEnabled !== false,
155+
paginationMode: "local",
155156
paginationSize: this.currentPageSize,
156157
movableColumns: true,
157158
// maxHeight: "100%",
@@ -181,6 +182,7 @@ export class Tabulator extends Table {
181182
delete config.data;
182183
config.pagination = true;
183184
config.paginationMode = "remote";
185+
config.paginationSize = this.currentPageSize,
184186
config.ajaxFiltering = true; // Tabulator v4.8
185187
config.filterMode = "remote"; // Tabulator v6.2
186188
config.ajaxSorting = true; // Tabulator v4.8

0 commit comments

Comments
 (0)