Skip to content

Commit

Permalink
Make cell-click filter in table viz optional
Browse files Browse the repository at this point in the history
 - Added table_filter checkbox in table viz
 - If set to false, clicking on a cell in table will not apply filter to
   dashboard
  • Loading branch information
vera-liu committed Dec 5, 2016
1 parent 2d0ebea commit b910ef3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion superset/assets/javascripts/explorev2/stores/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export const visTypes = {
['table_timestamp_format'],
['row_limit'],
['page_length'],
['include_search'],
['include_search', 'table_filter'],
],
},
],
Expand Down Expand Up @@ -1462,6 +1462,13 @@ export const fields = {
description: 'Whether to include a client side search box',
},

table_filter: {
type: 'CheckboxField',
label: 'Table Filter',
default: true,
description: 'Whether to apply filter when table cell is clicked',
},

show_bubbles: {
type: 'CheckboxField',
label: 'Show Bubbles',
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/visualizations/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function tableVis(slice) {
return (d.isMetric) ? d.val : null;
})
.on('click', function (d) {
if (!d.isMetric) {
if (!d.isMetric && fd.table_filter) {
const td = d3.select(this);
if (td.classed('filtered')) {
slice.removeFilter(d.col, [d.val]);
Expand Down
5 changes: 5 additions & 0 deletions superset/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@ def __init__(self, viz):
"description": _(
"Whether to include a client side search box")
}),
'table_filter': (BetterBooleanField, {
"label": _("Table Filter"),
"default": True,
"description": _("Whether to apply filter when table cell is clicked")
}),
'show_bubbles': (BetterBooleanField, {
"label": _("Show Bubbles"),
"default": False,
Expand Down
2 changes: 1 addition & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class TableViz(BaseViz):
'table_timestamp_format',
'row_limit',
'page_length',
('include_search', None),
('include_search', 'table_filter'),
)
})
form_overrides = ({
Expand Down

0 comments on commit b910ef3

Please sign in to comment.