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

Commit 6aa16df

Browse files
authored
Merge pull request #412 from plotly/row-ids
Row IDs
2 parents 54f0d7c + 9420590 commit 6aa16df

30 files changed

+805
-403
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,27 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1818
- new `eq` behavior (will attempt to convert and compare numeric values if possible)
1919
- new readonly `derived_filter_structure` prop exposing the query structure in a programmatically friendlier way
2020

21+
[#412](https://github.com/plotly/dash-table/pull/412)
22+
- Add support for row IDs, based on the `'id'` attribute of each row of `data`
23+
- IDs will not be displayed unless there is a column with `id='id'`
24+
- `active_cell`, `start_cell`, `end_cell`, and items in `selected_cells` contain row and column IDs: All are now dicts `{'row', 'column', 'row_id' and 'column_id'}` rather than arrays `[row, column]`.
25+
- Added new props mirroring all existing row indices props:
26+
- `selected_row_ids` mirrors `selected_rows`
27+
- `derived_viewport_row_ids` mirrors `derived_viewport_indices`
28+
- `derived_virtual_row_ids` mirrors `derived_virtual_indices`
29+
- `derived_viewport_selected_row_ids` mirrors `derived_viewport_selected_rows`
30+
- `derived_virtual_selected_row_ids` mirrors `derived_virtual_selected_rows`
31+
2132
### Changed
2233
[#397](https://github.com/plotly/dash-table/pull/397)
2334
- Rename `filtering_settings` to `filter`
2435

25-
[#412](https://github.com/plotly/dash-table/pull/412)
36+
[#417](https://github.com/plotly/dash-table/pull/417)
2637
- Rename `sorting_settings` to `sort_by`
2738

39+
[#412](https://github.com/plotly/dash-table/pull/412)
40+
- `active_cell` and `selected_cells` items are dicts `{'row', 'column', 'row_id' and 'column_id'}` instead of arrays `[row, column]`
41+
2842
## [3.6.0] - 2019-03-04
2943
### Fixed
3044
[#189](https://github.com/plotly/dash-table/issues/189)

dash_table/Format.py

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import collections
2-
import inspect
3-
import sys
42

53

64
def get_named_tuple(name, dict):
@@ -26,23 +24,23 @@ def get_named_tuple(name, dict):
2624
})
2725

2826
Prefix = get_named_tuple('prefix', {
29-
'yocto': 10**-24,
30-
'zepto': 10**-21,
31-
'atto': 10**-18,
32-
'femto': 10**-15,
33-
'pico': 10**-12,
34-
'nano': 10**-9,
35-
'micro': 10**-6,
36-
'milli': 10**-3,
27+
'yocto': 10 ** -24,
28+
'zepto': 10 ** -21,
29+
'atto': 10 ** -18,
30+
'femto': 10 ** -15,
31+
'pico': 10 ** -12,
32+
'nano': 10 ** -9,
33+
'micro': 10 ** -6,
34+
'milli': 10 ** -3,
3735
'none': None,
38-
'kilo': 10**3,
39-
'mega': 10**6,
40-
'giga': 10**9,
41-
'tera': 10**12,
42-
'peta': 10**15,
43-
'exa': 10**18,
44-
'zetta': 10**21,
45-
'yotta': 10**24
36+
'kilo': 10 ** 3,
37+
'mega': 10 ** 6,
38+
'giga': 10 ** 9,
39+
'tera': 10 ** 12,
40+
'peta': 10 ** 15,
41+
'exa': 10 ** 18,
42+
'zetta': 10 ** 21,
43+
'yotta': 10 ** 24
4644
})
4745

4846
Scheme = get_named_tuple('scheme', {
@@ -102,11 +100,17 @@ def __init__(self, **kwargs):
102100
'type': Scheme.default
103101
}
104102

105-
valid_methods = [m for m in dir(self.__class__) if m[0] != '_' and m != 'to_plotly_json']
103+
valid_methods = [
104+
m for m in dir(self.__class__)
105+
if m[0] != '_' and m != 'to_plotly_json'
106+
]
106107

107108
for kw, val in kwargs.items():
108109
if kw not in valid_methods:
109-
raise TypeError('{0} is not a format method. Expected one of'.format(kw), str(list(valid_methods)))
110+
raise TypeError(
111+
'{0} is not a format method. Expected one of'.format(kw),
112+
str(list(valid_methods))
113+
)
110114

111115
getattr(self, kw)(val)
112116

@@ -128,7 +132,8 @@ def _validate_non_negative_integer_or_none(self, value):
128132

129133
def _validate_named(self, value, named_values):
130134
if value not in named_values:
131-
raise TypeError('expected value to be one of', str(list(named_values)))
135+
raise TypeError('expected value to be one of',
136+
str(list(named_values)))
132137

133138
def _validate_string(self, value):
134139
if not isinstance(value, (str, u''.__class__)):
@@ -174,7 +179,9 @@ def padding_width(self, value):
174179
def precision(self, value):
175180
self._validate_non_negative_integer_or_none(value)
176181

177-
self._specifier['precision'] = '.{0}'.format(value) if value is not None else ''
182+
self._specifier['precision'] = (
183+
'.{0}'.format(value) if value is not None else ''
184+
)
178185
return self
179186

180187
def scheme(self, value):
@@ -238,13 +245,20 @@ def group_delimiter(self, value):
238245
return self
239246

240247
def groups(self, groups):
241-
groups = groups if isinstance(groups, list) else [groups] if isinstance(groups, int) else None
248+
groups = (
249+
groups if isinstance(groups, list) else
250+
[groups] if isinstance(groups, int) else None
251+
)
242252

243253
if not isinstance(groups, list):
244-
raise TypeError('expected groups to be an integer or a list of integers')
245-
254+
raise TypeError(
255+
'expected groups to be an integer or a list of integers'
256+
)
246257
if len(groups) == 0:
247-
raise ValueError('expected groups to be an integer or a list of one or more integers')
258+
raise ValueError(
259+
'expected groups to be an integer or a list of '
260+
'one or more integers'
261+
)
248262

249263
for group in groups:
250264
if not isinstance(group, int):
@@ -273,8 +287,9 @@ def to_plotly_json(self):
273287
f['locale'] = self._locale.copy()
274288
f['nully'] = self._nully
275289
f['prefix'] = self._prefix
290+
aligned = self._specifier['align'] != Align.default
276291
f['specifier'] = '{}{}{}{}{}{}{}{}{}{}'.format(
277-
self._specifier['fill'] if self._specifier['align'] != Align.default else '',
292+
self._specifier['fill'] if aligned else '',
278293
self._specifier['align'],
279294
self._specifier['sign'],
280295
self._specifier['symbol'],

dash_table/FormatTemplate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from enum import Enum
21
from .Format import Format, Group, Scheme, Sign, Symbol
32

43

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"private::host_dash8083": "python tests/cypress/dash/v_fe_page.py",
2323
"private::host_js": "http-server ./dash_table -c-1 --silent",
2424
"private::lint:ts": "tslint '{src,demo,tests}/**/*.{js,ts,tsx}' --exclude '**/@Types/*.*'",
25-
"private::lint:py": "flake8 --exclude=DataTable.py,__init__.py,_imports_.py --ignore=E501,F401,F841,F811,F821 dash_table",
25+
"private::lint:py": "flake8 --exclude=DataTable.py,__init__.py,_imports_.py dash_table",
2626
"private::wait_dash8081": "wait-on http://localhost:8081",
2727
"private::wait_dash8082": "wait-on http://localhost:8082",
2828
"private::wait_dash8083": "wait-on http://localhost:8083",

src/dash-table/components/CellFactory.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export default class CellFactory {
5050
} = this.props;
5151

5252
const operations = this.cellOperations(
53-
active_cell,
5453
data,
5554
virtualized.data,
5655
virtualized.indices,
@@ -114,4 +113,4 @@ export default class CellFactory {
114113
(o, c) => Array.prototype.concat(o, c)
115114
);
116115
}
117-
}
116+
}

0 commit comments

Comments
 (0)