ui.table
Creates a table from a list of pydantic models
Example:
:return: The current instance of the element.
from uiwiz import ui
from pydantic import BaseModel
class User(BaseModel):
id: int
name: str
email: str
data = [
User(id=1, name="John Doe", email="[email protected]"),
User(id=1, name="John Doe", email="[email protected]"),
]
ui.table(data, id_column_name="id")
Constructor
data: ListNo default required argument
id_column_name: Optional= None
Methods
after_render(html: str) -> str
This method is called after the element is rendered.
:param html: The rendered HTML of the element.
before_render() -> NoneType
No documentation providedclasses(input: str) -> Self
Set tailwind classes for the element.
:param input: The tailwind classes to apply to the element.
:return: The current instance of the element.
create_row(create: Union) -> Table
Enable creation functionality for a table row.
This method assigns the endpoint to handle the "Create" action for a row
in the table.
:param create: The endpoint that is triggered when the "Delete" action is performed.
:type create: FUNC_TYPE
:return: Returns the `Table` instance with the "Delete" functionality enabled.
:rtype: Table
Example:
>>> table = Table(data).create_row(create=create_endpoint)
delete_row(delete: Union) -> Table
Enable deletion functionality for a table row.
This method assigns the endpoint to handle the "Delete" action for rows
in the table. It requires that `id_column_name` be set to identify rows uniquely.
:param delete: The endpoint that is triggered when the "Delete" action is performed.
The callback should accept parameters required to handle the deletion logic.
:type delete: FUNC_TYPE
:return: Returns the `Table` instance with the "Delete" functionality enabled.
:rtype: Table
:raises ValueError: If `id_column_name` is not set, as it is required to identify rows
for the "Delete" operation.
Example:
>>> table = Table(data, id_column_name="id").delete_row(delete=delete_endpoint)
edit_row(edit: Union) -> Table
Enable editing functionality for a table row.
This method assigns the endpoint to handle the "Edit" action for rows
in the table. It requires that `id_column_name` be set to identify rows uniquely.
:param edit: The endpoint that is triggered when the "Edit" action is performed.
The callback should accept parameters required to handle the editing logic.
:type edit: FUNC_TYPE
:return: Returns the `Table` instance with the "Edit" functionality enabled.
:rtype: Table
:raises ValueError: If `id_column_name` is not set, as it is required to identify rows
for the "Edit" operation.
Example:
>>> table = Table(data, id_column_name="id").edit_row(edit=edit_endpoint)
get_classes() -> str
Get html classes of the element.
:return: The classes of the element.
:type: str
render(render_script: bool) -> str
Render the element as HTML.
:param render_script: If any element has a javascript script, it will be rendered as well.
:type render_script: bool
set_border(border_classes: str) -> Table
Set the border classes for the table
:param border_classes: The border classes to set
:return: The current instance of the element.
size(size: Literal) -> Self
Set the size of the element.
:param size: The size of the element.
:return: The current instance of the element.