Skip to content

Commit 12cedde

Browse files
authored
Merge pull request #172 from anvilistas/fix/selectableRows
2 parents 7720197 + 168b933 commit 12cedde

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ repos:
44
hooks:
55
- id: check-yaml
66
- id: end-of-file-fixer
7+
exclude: ".*/assets/tabulator-tables/.*"
78
- id: trailing-whitespace
9+
exclude: ".*/assets/tabulator-tables/.*"
810
- repo: https://github.com/psf/black
911
rev: 24.8.0 # Replace by any tag/version: https://github.com/psf/black/tags
1012
hooks:

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ This is most useful if you have multiple Tabulator components and don't want to
394394
The default `default_options` are:
395395

396396
```python
397-
Tabulator.default_options = {"layout": "fitColumns", "selectable": False}
397+
Tabulator.default_options = {"layout": "fitColumns"}
398398
```
399399
*(as well as all the JS Tabulator default options)*
400400

client_code/Tabulator/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
_ignore_resize_observer_error,
2323
_inject_theme,
2424
_merge,
25+
_normalizeOptions,
2526
_options_property,
2627
_spacing_property,
2728
_to_module,
@@ -133,6 +134,7 @@ def _initialize(self):
133134
logger.debug(f"Options: {self.options}")
134135

135136
options = _camelKeys(self._options) | _camelKeys(self.options)
137+
options = _normalizeOptions(options)
136138
options["columns"] = [_camelKeys(defn) for defn in options["columns"]]
137139
options["columnDefaults"] = _camelKeys(options["columnDefaults"])
138140
if in_designer and type(self) is Tabulator:
@@ -154,10 +156,9 @@ def _initialize(self):
154156
# if we're using the rowSelection make sure things are selectable
155157
if (
156158
any(col.get("formatter") == "rowSelection" for col in options["columns"])
157-
and options.get("selectable") is None
158-
and Tabulator.default_options.get("selectable") is False
159+
and options.get("selectableRows") is None
159160
):
160-
options["selectable"] = "highlight"
161+
options["selectableRows"] = "highlight"
161162

162163
t = _Tabulator(self._dom_node, options)
163164
t.anvil_form = self

client_code/Tabulator/_defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"Sort",
5050
}
5151

52-
_default_table_options = {"layout": "fitColumns", "selectable": False}
52+
_default_table_options = {"layout": "fitColumns"}
5353

5454

5555
_default_theme = "bootstrap3"

client_code/Tabulator/_helpers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ def _camelKeys(d):
2525
return {_toCamel(key): val for key, val in d.items()}
2626

2727

28+
def _normalizeOptions(options):
29+
# selectable was removed in tabulator 6 in favour of selectableRows
30+
# but we still support it for backwards compatibility
31+
if "selectable" in options:
32+
options["selectableRows"] = options["selectable"]
33+
del options["selectable"]
34+
return options
35+
36+
2837
def _merge(default, properties, **overrides):
2938
merged = overrides
3039
for key, val in default.items():

0 commit comments

Comments
 (0)