Sfoglia il codice sorgente

Merge branch 'main' of github.com:zauberzeug/nicegui

Rodja Trappe 2 anni fa
parent
commit
313283f771
2 ha cambiato i file con 19 aggiunte e 1 eliminazioni
  1. 1 1
      nicegui/elements/table.py
  2. 18 0
      tests/test_table.py

+ 1 - 1
nicegui/elements/table.py

@@ -31,4 +31,4 @@ class Table(Element):
         self.run_method('update_grid')
 
     def call_api_method(self, name: str, *args) -> None:
-        self.run_method('call_api_method', name, args)
+        self.run_method('call_api_method', name, *args)

+ 18 - 0
tests/test_table.py

@@ -62,3 +62,21 @@ def test_html_columns(screen: Screen):
     screen.should_contain('Alice')
     screen.should_not_contain('<span')
     assert 'text-bold' in screen.find('Alice').get_attribute('class')
+
+
+def test_call_api_method_with_argument(screen: Screen):
+    table = ui.table({
+        'columnDefs': [{'field': 'name', 'filter': True}],
+        'rowData': [{'name': 'Alice'}, {'name': 'Bob'}, {'name': 'Carol'}],
+    })
+    filter = {'name': {'filterType': 'text', 'type': 'equals', 'filter': 'Alice'}}
+    ui.button('Filter', on_click=lambda: table.call_api_method('setFilterModel', filter))
+
+    screen.open('/')
+    screen.should_contain('Alice')
+    screen.should_contain('Bob')
+    screen.should_contain('Carol')
+    screen.click('Filter')
+    screen.should_contain('Alice')
+    screen.should_not_contain('Bob')
+    screen.should_not_contain('Carol')