Skip to content

Commit

Permalink
[table viz] adding support for pagination (#1616)
Browse files Browse the repository at this point in the history
* [table viz] adding support for pagination

* linting
  • Loading branch information
mistercrunch authored Nov 17, 2016
1 parent c362f28 commit 267fd5b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
9 changes: 9 additions & 0 deletions superset/assets/javascripts/explorev2/stores/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export const visTypes = {
fieldSetRows: [
['table_timestamp_format'],
['row_limit'],
['page_length'],
['include_search'],
],
},
Expand Down Expand Up @@ -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',
Expand Down
9 changes: 8 additions & 1 deletion superset/assets/visualizations/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions superset/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ class TableViz(BaseViz):
'fields': (
'table_timestamp_format',
'row_limit',
'page_length',
('include_search', None),
)
})
Expand Down

0 comments on commit 267fd5b

Please sign in to comment.