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

[Table Viz] Table columns not match with group_by control #5329

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ export default class MetricsControl extends React.PureComponent {
}

onChange(opts) {
// if clear out options
if (opts === null) {
this.props.onChange(null);
return;
}

let transformedOpts = opts;
if (!this.props.multi) {
transformedOpts = [opts].filter(option => option);
Expand Down
8 changes: 7 additions & 1 deletion superset/assets/src/explore/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ export function getControlsState(state, form_data) {
control.default = control.default(control);
}
control.validationErrors = [];
control.value = formData[k] !== undefined ? formData[k] : control.default;
control.value = control.default;
// formData[k]'s type should match control value type
if (formData[k] !== undefined &&
(Array.isArray(formData[k]) && control.multi || !control.multi)
) {
control.value = formData[k];
}
controlsState[k] = control;
});
if (viz.onInit) {
Expand Down
2 changes: 1 addition & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def query_obj(self):
'Choose either fields to [Group By] and [Metrics] or '
'[Columns], not both'))

sort_by = fd.get('timeseries_limit_metric') or []
sort_by = fd.get('timeseries_limit_metric')
if fd.get('all_columns'):
d['columns'] = fd.get('all_columns')
d['groupby'] = []
Expand Down