Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit 2720f2b

Browse files
dmt0Shammamah Hossain
authored and
Shammamah Hossain
committed
Issue 539 - Booleans not showing (#593)
* Ensure booleans are showing * Changelog entry
1 parent 37f39e2 commit 2720f2b

File tree

5 files changed

+85
-5
lines changed

5 files changed

+85
-5
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ multi-line & ellipsis with `style_data` and other style props.
5050
[#583](https://github.com/plotly/dash-table/issues/583)
5151
- Fix regression when editing the content of a cell in a scrolled virtualized table
5252

53+
[#539](https://github.com/plotly/dash-table/issues/539)
54+
- Fix bug where boolean values are not showing up in the table
55+
5356
## [4.2.0] - 2019-08-27
5457
### Added
5558
[#317](https://github.com/plotly/dash-table/issues/317)

src/dash-table/components/CellLabel/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export default class CellLabel extends PureComponent<IProps> {
1717
return (<div
1818
className={className}
1919
>
20-
{value}
20+
{typeof value === 'boolean' ?
21+
value.toString() :
22+
value}
2123
</div>);
2224
}
2325
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ interface IDatumObject {
203203

204204
export interface IDropdownValue {
205205
label: string;
206-
value: string | number;
206+
value: string | number | boolean;
207207
}
208208

209209
export interface IDropdown {

src/dash-table/dash/DataTable.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,8 @@ export const propTypes = {
757757
label: PropTypes.string.isRequired,
758758
value: PropTypes.oneOfType([
759759
PropTypes.number,
760-
PropTypes.string
760+
PropTypes.string,
761+
PropTypes.bool
761762
]).isRequired
762763
})).isRequired
763764
})),
@@ -779,7 +780,8 @@ export const propTypes = {
779780
label: PropTypes.string.isRequired,
780781
value: PropTypes.oneOfType([
781782
PropTypes.number,
782-
PropTypes.string
783+
PropTypes.string,
784+
PropTypes.bool
783785
]).isRequired
784786
})).isRequired
785787
})),
@@ -797,7 +799,8 @@ export const propTypes = {
797799
label: PropTypes.string.isRequired,
798800
value: PropTypes.oneOfType([
799801
PropTypes.number,
800-
PropTypes.string
802+
PropTypes.string,
803+
PropTypes.bool
801804
]).isRequired
802805
})).isRequired
803806
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import * as R from 'ramda';
2+
import React from 'react';
3+
import { storiesOf } from '@storybook/react';
4+
import DataTable from 'dash-table/dash/DataTable';
5+
6+
const setProps = () => { };
7+
const columns: { name: string[]; id: string; presentation?: string }[] = [
8+
{ name: ['String'], id: 'string' },
9+
{ name: ['Number'], id: 'number' },
10+
{ name: ['Date'], id: 'date' },
11+
{ name: ['Boolean'], id: 'boolean' },
12+
{ name: ['Any'], id: 'any' },
13+
];
14+
15+
const columns_dd = columns.map(i => ({...i, presentation: 'dropdown'}));
16+
17+
storiesOf('DashTable/Types', module)
18+
.add('types input', () => (<DataTable
19+
setProps={setProps}
20+
id='types input'
21+
data={[
22+
{ string: 'Montreal', number: 1, date: '2015-01-01', boolean: true, any: 'Montreal' },
23+
{ string: 'Vermont', number: 2, date: '2015-10-24', boolean: false, any: 1 },
24+
{ string: 'New York City' , number: 3, date: '2016-05-10', boolean: true, any: '2015-01-01' },
25+
{ string: 'Boston', number: 4, date: '2017-11-11', boolean: false, any: true },
26+
]}
27+
columns={columns}
28+
/>))
29+
.add('types dropdown', () => (<DataTable
30+
setProps={setProps}
31+
id='types dropdown'
32+
data={[
33+
{ string: 'Montreal', number: 1, date: '2015-01-01', boolean: true, any: 'Montreal' },
34+
{ string: 'Vermont', number: 2, date: '2015-10-24', boolean: false, any: 1 },
35+
{ string: 'New York City' , number: 3, date: '2016-05-10', boolean: true, any: '2015-01-01' },
36+
{ string: 'Boston', number: 4, date: '2017-11-11', boolean: false, any: true },
37+
]}
38+
columns={columns_dd}
39+
editable={false}
40+
dropdown={{
41+
string: {
42+
options: R.map(
43+
i => ({ label: `label: ${i}`, value: i }),
44+
['Montreal', 'Vermont', 'New York City', 'Boston']
45+
)
46+
},
47+
number: {
48+
options: R.map(
49+
i => ({ label: `label: ${i}`, value: i }),
50+
[1, 2, 3, 4]
51+
)
52+
},
53+
date: {
54+
options: R.map(
55+
i => ({ label: `label: ${i}`, value: i }),
56+
['2015-01-01', '2015-10-24', '2016-05-10', '2017-11-11']
57+
)
58+
},
59+
boolean: {
60+
options: R.map(
61+
i => ({ label: `label: ${i}`, value: i }),
62+
[true, false]
63+
)
64+
},
65+
any: {
66+
options: R.map(
67+
i => ({ label: `label: ${i}`, value: i }),
68+
['Montreal', 1, '2015-01-01', true]
69+
)
70+
}
71+
}}
72+
/>));

0 commit comments

Comments
 (0)