table.py 728 B

123456789101112131415161718192021222324252627
  1. import asyncio
  2. from typing import Dict
  3. import justpy as jp
  4. from ..task_logger import create_task
  5. from .element import Element
  6. jp.template_options['aggrid'] = False
  7. class Table(Element):
  8. def __init__(self, options: Dict):
  9. """Table
  10. An element to create a table using `AG Grid <https://www.ag-grid.com/>`_.
  11. :param options: dictionary of AG Grid options
  12. """
  13. view = jp.AgGrid(temp=False)
  14. view.options = self.options = jp.Dict(**options)
  15. super().__init__(view)
  16. if not jp.template_options['aggrid'] and asyncio.get_event_loop().is_running():
  17. create_task(self.page.run_javascript('location.reload()'))
  18. jp.template_options['aggrid'] = True