Skip to content

Commit 5f71249

Browse files
authored
Merge pull request #173 from chrAnvil/resize-cells
2 parents 12cedde + 9980e8f commit 5f71249

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

client_code/Tabulator/_custom_modules.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from anvil import Component
66
from anvil.js import get_dom_node, report_exceptions
7-
from anvil.js.window import Function, document, window
7+
from anvil.js.window import Function, ResizeObserver, document, window
88

99
from ._helpers import assert_no_suspension
1010
from ._module_helpers import AbstractModule, tabulator_module
@@ -44,8 +44,24 @@ def cell_format(self, cell, component):
4444
cell.modules.anvilComponent = component
4545
if component.visible:
4646
component.visible = None
47+
domNode = get_dom_node(component)
48+
49+
def on_resize(*args):
50+
cell.checkHeight()
51+
52+
observer = ResizeObserver(on_resize)
53+
54+
def page_added(**args):
55+
observer.observe(domNode)
56+
57+
def page_removed(**args):
58+
observer.disconnect()
59+
60+
observer.observe(domNode)
61+
component.add_event_handler("x-anvil-page-added", page_added)
62+
component.add_event_handler("x-page-removed", page_removed)
4763
self.table.anvil_form.add_component(component)
48-
return get_dom_node(component)
64+
return domNode
4965

5066
def cell_render(self, cell):
5167
component = cell.modules.get("anvilComponent")

0 commit comments

Comments
 (0)