Skip to content

Commit 813b156

Browse files
add back support for column options and dropdown_properties (plotly#89)
* add back support for column options and dropdown_properties * fix lint
1 parent 1784d95 commit 813b156

File tree

7 files changed

+29
-5
lines changed

7 files changed

+29
-5
lines changed

packages/dash-table/dash_table/bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dash-table/dash_table/demo.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dash-table/dash_table/metadata.json

+7
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,13 @@
642642
"computed": false
643643
}
644644
},
645+
"dropdown_properties": {
646+
"type": {
647+
"name": "any"
648+
},
649+
"required": false,
650+
"description": ""
651+
},
645652
"column_conditional_styles": {
646653
"defaultValue": {
647654
"value": "[]",

packages/dash-table/src/dash-table/Table.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ export const propTypes = {
168168
sorting_treat_empty_string_as_none: PropTypes.bool,
169169

170170
virtual_dataframe: PropTypes.arrayOf(PropTypes.object),
171-
virtual_dataframe_indices: PropTypes.arrayOf(PropTypes.number)
171+
virtual_dataframe_indices: PropTypes.arrayOf(PropTypes.number),
172+
173+
dropdown_properties: PropTypes.any,
172174
};
173175

174176
Table.defaultProps = defaultProps;

packages/dash-table/src/dash-table/components/CellFactory.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ export default class CellFactory {
210210
column_conditional_styles,
211211
column_static_dropdown,
212212
column_static_style,
213+
dropdown_properties, // legacy
213214
editable,
214215
id,
215216
is_focused,
@@ -236,6 +237,18 @@ export default class CellFactory {
236237
const cells = visibleColumns.map((column, visibleIndex) => {
237238
visibleIndex += offset;
238239

240+
let legacyDropdown: any = (
241+
(
242+
dropdown_properties &&
243+
dropdown_properties[column.id] &&
244+
(
245+
dropdown_properties[column.id].length > realIdx ?
246+
dropdown_properties[column.id][realIdx] :
247+
null
248+
)
249+
) || column || {}
250+
).options;
251+
239252
const index = columns.indexOf(column);
240253

241254
const classes = [`column-${index + offset}`];
@@ -244,7 +257,7 @@ export default class CellFactory {
244257
let staticDropdown = column_static_dropdown.find((sd: any) => sd.id === column.id);
245258

246259
conditionalDropdowns = conditionalDropdowns && conditionalDropdowns.dropdowns;
247-
staticDropdown = staticDropdown && staticDropdown.dropdown;
260+
staticDropdown = legacyDropdown || (staticDropdown && staticDropdown.dropdown);
248261

249262
let conditionalStyles = column_conditional_styles.find((cs: any) => cs.id === column.id);
250263
let staticStyle = column_static_style.find((ss: any) => ss.id === column.id);

packages/dash-table/src/dash-table/components/ControlledTable/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ export default class ControlledTable extends Component<ControlledTableProps> {
491491

492492
const noOffsetActiveCell: [number, number] = [active_cell[0], active_cell[1] - columnIndexOffset];
493493

494-
495494
const result = TableClipboardHelper.fromClipboard(
496495
e,
497496
noOffsetActiveCell,

packages/dash-table/src/dash-table/components/Table/props.ts

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type Virtualization = 'fe' | 'be' | boolean;
1919
interface IColumn {
2020
id: string | number;
2121
editable?: boolean;
22+
options?: { label: string | number, value: any }[]; // legacy
2223
[key: string]: any;
2324
}
2425

@@ -48,6 +49,7 @@ interface IProps {
4849
column_static_dropdown?: any;
4950
column_static_style?: any;
5051
dataframe?: Dataframe;
52+
dropdown_properties: any; // legacy
5153
editable?: boolean;
5254
filtering?: Filtering;
5355
filtering_settings?: string;
@@ -118,6 +120,7 @@ export interface ICellFactoryOptions {
118120
column_static_dropdown: any;
119121
column_static_style: any;
120122
dataframe: Dataframe;
123+
dropdown_properties: any; // legacy
121124
editable: boolean;
122125
id: string;
123126
is_focused?: boolean;

0 commit comments

Comments
 (0)