diff --git a/superset/assets/javascripts/explorev2/stores/store.js b/superset/assets/javascripts/explorev2/stores/store.js index 1b413f9c4ac11..504f7029baf6d 100644 --- a/superset/assets/javascripts/explorev2/stores/store.js +++ b/superset/assets/javascripts/explorev2/stores/store.js @@ -245,6 +245,7 @@ export const visTypes = { fieldSetRows: [ ['table_timestamp_format'], ['row_limit'], + ['page_length'], ['include_search'], ], }, @@ -1285,6 +1286,14 @@ export const fields = { description: 'Pixel height of each series', }, + page_length: { + type: 'FreeFormSelectField', + label: 'Page Length', + default: 0, + choices: formatSelectOptions([0, 10, 25, 40, 50, 75, 100, 150, 200]), + description: 'Rows per page, 0 means no pagination', + }, + x_axis_format: { type: 'FreeFormSelectField', label: 'X axis format', diff --git a/superset/assets/visualizations/table.js b/superset/assets/visualizations/table.js index be4aa817f9ca4..78f5af92bf094 100644 --- a/superset/assets/visualizations/table.js +++ b/superset/assets/visualizations/table.js @@ -127,8 +127,15 @@ function tableVis(slice) { return d.val; }); const height = slice.height(); + let paging = false; + let pageLength; + if (fd.page_length && fd.page_length > 0) { + paging = true; + pageLength = parseInt(fd.page_length, 10); + } const datatable = container.find('.dataTable').DataTable({ - paging: false, + paging, + pageLength, aaSorting: [], searching: fd.include_search, bInfo: false, diff --git a/superset/forms.py b/superset/forms.py index 0febecc2afb1d..b568957891d76 100755 --- a/superset/forms.py +++ b/superset/forms.py @@ -343,6 +343,13 @@ def __init__(self, viz): "Bottom marging, in pixels, allowing for more room for " "axis labels"), }), + 'page_length': (FreeFormSelectField, { + "label": _("Page Length"), + "default": 0, + "choices": self.choicify([0, 10, 25, 50, 100, 250, 500]), + "description": _( + "Number of rows per page, 0 means no pagination") + }), 'granularity': (FreeFormSelectField, { "label": _("Time Granularity"), "default": "one day", @@ -957,8 +964,9 @@ def __init__(self, viz): 'render_while_dragging': (BetterBooleanField, { "label": _("Live render"), "default": True, - "description": _("Points and clusters will update as viewport " - "is being changed") + "description": _( + "Points and clusters will update as viewport " + "is being changed"), }), 'mapbox_color': (FreeFormSelectField, { "label": _("RGB Color"), diff --git a/superset/viz.py b/superset/viz.py index abdea0ff68901..d92620efdd274 100755 --- a/superset/viz.py +++ b/superset/viz.py @@ -420,6 +420,7 @@ class TableViz(BaseViz): 'fields': ( 'table_timestamp_format', 'row_limit', + 'page_length', ('include_search', None), ) })