dhxpyt.cardflow

1from .cardflow import CardFlow
2from .cardflow_config import CardFlowConfig, CardFlowColumnConfig
3
4__all__ = ["CardFlow", "CardFlowConfig", "CardFlowColumnConfig"]
class CardFlow:
  9class CardFlow:
 10    """
 11    Wrapper class for the CardFlow widget.
 12    """
 13    def __init__(self, config: CardFlowConfig, container: str = None):
 14        """
 15        :param config: An instance of CardFlowConfig describing columns, data, etc.
 16        :param container: An optional reference to a layout cell or container ID where the JS CardFlow is attached.
 17        """
 18        # Convert the config to a dictionary and initialize the CardFlow widget
 19        config_dict = config.to_dict()
 20        self.cardflow = js.customdhx.CardFlow.new(
 21            container,
 22            js.JSON.parse(json.dumps(config_dict))
 23        )
 24        
 25        # Dictionary to store event handlers (if you want to store them for potential removal)
 26        self.event_handlers = {}
 27
 28    def on_sort(self, handler: Callable) -> None:
 29        """
 30        Placeholder for a sort event if the JS side triggers a "sort" event.
 31        Currently, the main code does not raise a custom "sort" event, so you may 
 32        want to capture the sorting user action differently or modify the JS code 
 33        to fire an event.
 34        """
 35        event_proxy = create_proxy(handler)
 36        self.cardflow.events.on("sort", event_proxy)
 37
 38    def on_card_options(self, handler: Callable) -> None:
 39        """
 40        Called when card's options (e.g., dots menu) are used.
 41        """
 42        event_proxy = create_proxy(handler)
 43        self.cardflow.onOptions = event_proxy
 44
 45
 46    def on_card_expand(self, handler: Callable) -> None:
 47        """
 48        Called when a card is expanded.
 49        """
 50        event_proxy = create_proxy(handler)
 51        self.cardflow.onExpand = event_proxy
 52
 53    def on_card_collapse(self, handler: Callable) -> None:
 54        """
 55        Called when a card is collapsed.
 56        """
 57        event_proxy = create_proxy(handler)
 58        self.cardflow.onCollapse = event_proxy
 59
 60    def on_options(self, handler: Callable) -> None:
 61        """
 62        Same as above for on_card_options, if you prefer a shorter name.
 63        """
 64        event_proxy = create_proxy(handler)
 65        self.cardflow.onOptions = event_proxy
 66
 67    def update_header(self):
 68        """
 69        If your JS code has a method named updateHeader, call it here.
 70        Otherwise, remove or adjust as needed.
 71        """
 72        if hasattr(self.cardflow, "updateHeader"):
 73            self.cardflow.updateHeader()
 74
 75    def set_row_color(self, row_id, color):
 76        self.cardflow.setRowColor(row_id, color)
 77
 78    def set_row_font_size(self, row_id, font_size):
 79        self.cardflow.setRowFontSize(row_id, font_size)
 80
 81    def set_row_data_value(self, row_id, column_id, value):
 82        self.cardflow.setRowDataValue(row_id, column_id, value)
 83
 84    def toggle_header(self, show=None):
 85        self.cardflow.toggleHeader(show)
 86
 87    def toggle_sort(self, show=None):
 88        self.cardflow.toggleSort(show)
 89
 90    def toggle_data_headers(self, show=None):
 91        self.cardflow.toggleDataHeaders(show)
 92
 93    def set_theme(self, theme: str) -> None:
 94        """
 95        If your JS code supports a setTheme method, or if you have a theme mechanism, call it here.
 96        Otherwise, remove.
 97        """
 98        if hasattr(self.cardflow, "setTheme"):
 99            self.cardflow.setTheme(js.JSON.parse(json.dumps({"name": theme, "fonts": True})))
100
101    def export_to_json(self) -> str:
102        """
103        Exports the current data to JSON. If your JS code actually supports data.serialize(), this will work.
104        """
105        if hasattr(self.cardflow, "data") and hasattr(self.cardflow.data, "serialize"):
106            return self.cardflow.data.serialize()
107        return ""
108
109    def collapse_all(self) -> None:
110        """
111        Collapses all cards (if the underlying JS code includes collapseAll()).
112        """
113        self.cardflow.collapseAll()
114
115    def expand_all(self) -> None:
116        """
117        Expands all cards (if the underlying JS code includes expandAll()).
118        """
119        self.cardflow.expandAll()
120
121    def add_layout(self, id: str = "mainwindow", layout_config=None):
122        """
123        Example of how you might nest a dhtmlx Layout inside a card's content.
124        This calls attach_to_card_content to wire up the new layout widget. 
125        Modify as needed for your application.
126        """
127        from ..layout import Layout
128        layout_widget = Layout(config=layout_config)
129        self.attach_to_card_content(id, layout_widget.layout)
130        return layout_widget
131
132    def attach_to_card_content(self, cardid: str, widget: Any) -> None:
133        """
134        Attach a (JS) widget to a card's content area when expanded.
135        Passing in the cardid and the widget (which might be another dhtmlx object).
136        """
137        self.cardflow.attachToCardContent(cardid, widget)
138
139    def detach_from_card_content(self, cardid: str) -> None:
140        """
141        Removes a widget from the card's content area.
142        """
143        self.cardflow.detachCardFromContent(cardid)

Wrapper class for the CardFlow widget.

CardFlow( config: CardFlowConfig, container: str = None)
13    def __init__(self, config: CardFlowConfig, container: str = None):
14        """
15        :param config: An instance of CardFlowConfig describing columns, data, etc.
16        :param container: An optional reference to a layout cell or container ID where the JS CardFlow is attached.
17        """
18        # Convert the config to a dictionary and initialize the CardFlow widget
19        config_dict = config.to_dict()
20        self.cardflow = js.customdhx.CardFlow.new(
21            container,
22            js.JSON.parse(json.dumps(config_dict))
23        )
24        
25        # Dictionary to store event handlers (if you want to store them for potential removal)
26        self.event_handlers = {}
Parameters
  • config: An instance of CardFlowConfig describing columns, data, etc.
  • container: An optional reference to a layout cell or container ID where the JS CardFlow is attached.
cardflow
event_handlers
def on_sort(self, handler: Callable) -> None:
28    def on_sort(self, handler: Callable) -> None:
29        """
30        Placeholder for a sort event if the JS side triggers a "sort" event.
31        Currently, the main code does not raise a custom "sort" event, so you may 
32        want to capture the sorting user action differently or modify the JS code 
33        to fire an event.
34        """
35        event_proxy = create_proxy(handler)
36        self.cardflow.events.on("sort", event_proxy)

Placeholder for a sort event if the JS side triggers a "sort" event. Currently, the main code does not raise a custom "sort" event, so you may want to capture the sorting user action differently or modify the JS code to fire an event.

def on_card_options(self, handler: Callable) -> None:
38    def on_card_options(self, handler: Callable) -> None:
39        """
40        Called when card's options (e.g., dots menu) are used.
41        """
42        event_proxy = create_proxy(handler)
43        self.cardflow.onOptions = event_proxy

Called when card's options (e.g., dots menu) are used.

def on_card_expand(self, handler: Callable) -> None:
46    def on_card_expand(self, handler: Callable) -> None:
47        """
48        Called when a card is expanded.
49        """
50        event_proxy = create_proxy(handler)
51        self.cardflow.onExpand = event_proxy

Called when a card is expanded.

def on_card_collapse(self, handler: Callable) -> None:
53    def on_card_collapse(self, handler: Callable) -> None:
54        """
55        Called when a card is collapsed.
56        """
57        event_proxy = create_proxy(handler)
58        self.cardflow.onCollapse = event_proxy

Called when a card is collapsed.

def on_options(self, handler: Callable) -> None:
60    def on_options(self, handler: Callable) -> None:
61        """
62        Same as above for on_card_options, if you prefer a shorter name.
63        """
64        event_proxy = create_proxy(handler)
65        self.cardflow.onOptions = event_proxy

Same as above for on_card_options, if you prefer a shorter name.

def update_header(self):
67    def update_header(self):
68        """
69        If your JS code has a method named updateHeader, call it here.
70        Otherwise, remove or adjust as needed.
71        """
72        if hasattr(self.cardflow, "updateHeader"):
73            self.cardflow.updateHeader()

If your JS code has a method named updateHeader, call it here. Otherwise, remove or adjust as needed.

def set_row_color(self, row_id, color):
75    def set_row_color(self, row_id, color):
76        self.cardflow.setRowColor(row_id, color)
def set_row_font_size(self, row_id, font_size):
78    def set_row_font_size(self, row_id, font_size):
79        self.cardflow.setRowFontSize(row_id, font_size)
def set_row_data_value(self, row_id, column_id, value):
81    def set_row_data_value(self, row_id, column_id, value):
82        self.cardflow.setRowDataValue(row_id, column_id, value)
def toggle_header(self, show=None):
84    def toggle_header(self, show=None):
85        self.cardflow.toggleHeader(show)
def toggle_sort(self, show=None):
87    def toggle_sort(self, show=None):
88        self.cardflow.toggleSort(show)
def toggle_data_headers(self, show=None):
90    def toggle_data_headers(self, show=None):
91        self.cardflow.toggleDataHeaders(show)
def set_theme(self, theme: str) -> None:
93    def set_theme(self, theme: str) -> None:
94        """
95        If your JS code supports a setTheme method, or if you have a theme mechanism, call it here.
96        Otherwise, remove.
97        """
98        if hasattr(self.cardflow, "setTheme"):
99            self.cardflow.setTheme(js.JSON.parse(json.dumps({"name": theme, "fonts": True})))

If your JS code supports a setTheme method, or if you have a theme mechanism, call it here. Otherwise, remove.

def export_to_json(self) -> str:
101    def export_to_json(self) -> str:
102        """
103        Exports the current data to JSON. If your JS code actually supports data.serialize(), this will work.
104        """
105        if hasattr(self.cardflow, "data") and hasattr(self.cardflow.data, "serialize"):
106            return self.cardflow.data.serialize()
107        return ""

Exports the current data to JSON. If your JS code actually supports data.serialize(), this will work.

def collapse_all(self) -> None:
109    def collapse_all(self) -> None:
110        """
111        Collapses all cards (if the underlying JS code includes collapseAll()).
112        """
113        self.cardflow.collapseAll()

Collapses all cards (if the underlying JS code includes collapseAll()).

def expand_all(self) -> None:
115    def expand_all(self) -> None:
116        """
117        Expands all cards (if the underlying JS code includes expandAll()).
118        """
119        self.cardflow.expandAll()

Expands all cards (if the underlying JS code includes expandAll()).

def add_layout(self, id: str = 'mainwindow', layout_config=None):
121    def add_layout(self, id: str = "mainwindow", layout_config=None):
122        """
123        Example of how you might nest a dhtmlx Layout inside a card's content.
124        This calls attach_to_card_content to wire up the new layout widget. 
125        Modify as needed for your application.
126        """
127        from ..layout import Layout
128        layout_widget = Layout(config=layout_config)
129        self.attach_to_card_content(id, layout_widget.layout)
130        return layout_widget

Example of how you might nest a dhtmlx Layout inside a card's content. This calls attach_to_card_content to wire up the new layout widget. Modify as needed for your application.

def attach_to_card_content(self, cardid: str, widget: Any) -> None:
132    def attach_to_card_content(self, cardid: str, widget: Any) -> None:
133        """
134        Attach a (JS) widget to a card's content area when expanded.
135        Passing in the cardid and the widget (which might be another dhtmlx object).
136        """
137        self.cardflow.attachToCardContent(cardid, widget)

Attach a (JS) widget to a card's content area when expanded. Passing in the cardid and the widget (which might be another dhtmlx object).

def detach_from_card_content(self, cardid: str) -> None:
139    def detach_from_card_content(self, cardid: str) -> None:
140        """
141        Removes a widget from the card's content area.
142        """
143        self.cardflow.detachCardFromContent(cardid)

Removes a widget from the card's content area.

class CardFlowConfig:
 63class CardFlowConfig:
 64    """
 65    Configuration class for the CardFlow widget.
 66    Example structure:
 67    {
 68        "columns": [
 69            { "id": "name", "header": "Name:" },
 70            { "id": "vehicle", "header": "Vehicle:" },
 71            { "id": "status", "header": "Status:" },
 72            { "id": "promise_time", "header": "Promise Time:" }
 73        ],
 74        "data": [ ... ],
 75        "cardHeight": "120px",
 76        "stacked": True
 77    }
 78    """
 79    def __init__(
 80        self,
 81        columns: List[Union[Dict[str, Any], CardFlowColumnConfig]] = None,
 82        data: List[Dict[str, Any]] = None,
 83        editable: bool = True,
 84        group: Dict[str, Any] = None,
 85        groupable: bool = True,
 86        hideExpandCollapse: bool = False,
 87        autoCollapse: bool = False,
 88        optionItems: List[Dict[str, Any]] = None,
 89        sortDisabled: bool = False,
 90        showHeader: bool = True,
 91        showSort: bool = True,
 92        sortHeader: str = "",
 93        showDataHeaders: bool = True,
 94        showOptions: bool = True,
 95        fontSize: str = "",
 96        cardHeight: str = None,  # NEW: pass a string like "120px" (defaults to "auto" in JS)
 97        stacked: bool = False   # NEW: pass True/False for stacked layout
 98    ):
 99        """
100        Initializes the CardFlowConfig.
101
102        :param columns: List of column configurations (dict or CardFlowColumnConfig).
103        :param data: A list of dictionaries containing the CardFlow data (each representing one card).
104        :param editable: Whether the CardFlow is editable.
105        :param group: Optional grouping config (not always used).
106        :param groupable: Whether grouping is enabled (not always used).
107        :param hideExpandCollapse: If set to True, you might hide the expand/collapse UI.
108        :param optionItems: Specifies items for the "options" dropdown.
109        :param sortDisabled: Disables the sorting toolbar if True.
110        :param sortHeader: Label/text to show on the sorting toolbar.
111        :param cardHeight: Height (CSS) of each card row, e.g. "100px". Defaults to "auto" in JS if not set.
112        :param stacked: If True, card data displays in vertical (stacked) format rather than side-by-side grid.
113        """
114        self.columns = columns if columns is not None else []
115        self.data = data if data is not None else []
116        self.editable = editable
117        self.group = group if group is not None else {}
118        self.groupable = groupable
119        self.hideExpandCollapse = hideExpandCollapse
120        self.autoCollapse = autoCollapse
121        self.sortDisabled = sortDisabled
122        self.sortHeader = sortHeader
123        self.cardHeight = cardHeight
124        self.stacked = stacked
125        self.optionItems = optionItems
126        self.showHeader = showHeader
127        self.showSort = showSort
128        self.showDataHeaders = showDataHeaders
129        self.fontSize = fontSize
130        self.showOptions = showOptions
131
132    def to_dict(self) -> Dict[str, Any]:
133        """
134        Converts the CardFlowConfig into a dictionary format for the JS code.
135        """
136        config_dict = {
137            "columns": [
138                col.to_dict() if hasattr(col, "to_dict") else col 
139                for col in self.columns
140            ],
141            "data": self.data,
142            "editable": self.editable,
143            "group": self.group,
144            "groupable": self.groupable,
145            "hideExpandCollapse": self.hideExpandCollapse,
146            "autoCollapse": self.autoCollapse,
147            "optionItems": self.optionItems,
148            "sortDisabled": self.sortDisabled,
149            "sortHeader": self.sortHeader,
150            # new parameters
151            "cardHeight": self.cardHeight,
152            "stacked": self.stacked,
153            "showHeader": self.showHeader,
154            "showSort": self.showSort,
155            "showDataHeaders": self.showDataHeaders,
156            "fontSize": self.fontSize,
157            "showOptions": self.showOptions
158        }
159        # Remove keys with None values
160        return {k: v for k, v in config_dict.items() if v is not None}

Configuration class for the CardFlow widget. Example structure: { "columns": [ { "id": "name", "header": "Name:" }, { "id": "vehicle", "header": "Vehicle:" }, { "id": "status", "header": "Status:" }, { "id": "promise_time", "header": "Promise Time:" } ], "data": [ ... ], "cardHeight": "120px", "stacked": True }

CardFlowConfig( columns: List[Union[Dict[str, Any], CardFlowColumnConfig]] = None, data: List[Dict[str, Any]] = None, editable: bool = True, group: Dict[str, Any] = None, groupable: bool = True, hideExpandCollapse: bool = False, autoCollapse: bool = False, optionItems: List[Dict[str, Any]] = None, sortDisabled: bool = False, showHeader: bool = True, showSort: bool = True, sortHeader: str = '', showDataHeaders: bool = True, showOptions: bool = True, fontSize: str = '', cardHeight: str = None, stacked: bool = False)
 79    def __init__(
 80        self,
 81        columns: List[Union[Dict[str, Any], CardFlowColumnConfig]] = None,
 82        data: List[Dict[str, Any]] = None,
 83        editable: bool = True,
 84        group: Dict[str, Any] = None,
 85        groupable: bool = True,
 86        hideExpandCollapse: bool = False,
 87        autoCollapse: bool = False,
 88        optionItems: List[Dict[str, Any]] = None,
 89        sortDisabled: bool = False,
 90        showHeader: bool = True,
 91        showSort: bool = True,
 92        sortHeader: str = "",
 93        showDataHeaders: bool = True,
 94        showOptions: bool = True,
 95        fontSize: str = "",
 96        cardHeight: str = None,  # NEW: pass a string like "120px" (defaults to "auto" in JS)
 97        stacked: bool = False   # NEW: pass True/False for stacked layout
 98    ):
 99        """
100        Initializes the CardFlowConfig.
101
102        :param columns: List of column configurations (dict or CardFlowColumnConfig).
103        :param data: A list of dictionaries containing the CardFlow data (each representing one card).
104        :param editable: Whether the CardFlow is editable.
105        :param group: Optional grouping config (not always used).
106        :param groupable: Whether grouping is enabled (not always used).
107        :param hideExpandCollapse: If set to True, you might hide the expand/collapse UI.
108        :param optionItems: Specifies items for the "options" dropdown.
109        :param sortDisabled: Disables the sorting toolbar if True.
110        :param sortHeader: Label/text to show on the sorting toolbar.
111        :param cardHeight: Height (CSS) of each card row, e.g. "100px". Defaults to "auto" in JS if not set.
112        :param stacked: If True, card data displays in vertical (stacked) format rather than side-by-side grid.
113        """
114        self.columns = columns if columns is not None else []
115        self.data = data if data is not None else []
116        self.editable = editable
117        self.group = group if group is not None else {}
118        self.groupable = groupable
119        self.hideExpandCollapse = hideExpandCollapse
120        self.autoCollapse = autoCollapse
121        self.sortDisabled = sortDisabled
122        self.sortHeader = sortHeader
123        self.cardHeight = cardHeight
124        self.stacked = stacked
125        self.optionItems = optionItems
126        self.showHeader = showHeader
127        self.showSort = showSort
128        self.showDataHeaders = showDataHeaders
129        self.fontSize = fontSize
130        self.showOptions = showOptions

Initializes the CardFlowConfig.

Parameters
  • columns: List of column configurations (dict or CardFlowColumnConfig).
  • data: A list of dictionaries containing the CardFlow data (each representing one card).
  • editable: Whether the CardFlow is editable.
  • group: Optional grouping config (not always used).
  • groupable: Whether grouping is enabled (not always used).
  • hideExpandCollapse: If set to True, you might hide the expand/collapse UI.
  • optionItems: Specifies items for the "options" dropdown.
  • sortDisabled: Disables the sorting toolbar if True.
  • sortHeader: Label/text to show on the sorting toolbar.
  • cardHeight: Height (CSS) of each card row, e.g. "100px". Defaults to "auto" in JS if not set.
  • stacked: If True, card data displays in vertical (stacked) format rather than side-by-side grid.
columns
data
editable
group
groupable
hideExpandCollapse
autoCollapse
sortDisabled
sortHeader
cardHeight
stacked
optionItems
showHeader
showSort
showDataHeaders
fontSize
showOptions
def to_dict(self) -> Dict[str, Any]:
132    def to_dict(self) -> Dict[str, Any]:
133        """
134        Converts the CardFlowConfig into a dictionary format for the JS code.
135        """
136        config_dict = {
137            "columns": [
138                col.to_dict() if hasattr(col, "to_dict") else col 
139                for col in self.columns
140            ],
141            "data": self.data,
142            "editable": self.editable,
143            "group": self.group,
144            "groupable": self.groupable,
145            "hideExpandCollapse": self.hideExpandCollapse,
146            "autoCollapse": self.autoCollapse,
147            "optionItems": self.optionItems,
148            "sortDisabled": self.sortDisabled,
149            "sortHeader": self.sortHeader,
150            # new parameters
151            "cardHeight": self.cardHeight,
152            "stacked": self.stacked,
153            "showHeader": self.showHeader,
154            "showSort": self.showSort,
155            "showDataHeaders": self.showDataHeaders,
156            "fontSize": self.fontSize,
157            "showOptions": self.showOptions
158        }
159        # Remove keys with None values
160        return {k: v for k, v in config_dict.items() if v is not None}

Converts the CardFlowConfig into a dictionary format for the JS code.

class CardFlowColumnConfig:
 4class CardFlowColumnConfig:
 5    """
 6    Configuration class for CardFlow columns.
 7    Similar to GridColumnConfig, lets you control properties like width, header text, etc.
 8    """
 9    def __init__(
10        self,
11        id: str,
12        header: Union[str, Dict[str, Any]],
13        width: Union[int, str] = "100px",
14        align: str = None,
15        hidden: bool = False,
16        css: str = None,
17        dataType: str = "str",
18        dataFormat: str = "",
19        applyFormat: bool = False,
20        coltype: str = ""
21    ):
22        """
23        Initializes a CardFlow column configuration.
24        
25        :param id: Unique identifier for the column.
26        :param header: Header text or a more complex header config.
27        :param width: Column width (e.g., "100px" or 100).
28        :param align: Alignment for cell content.
29        :param hidden: Whether the column is hidden.
30        :param css: Additional CSS classes.
31        :param dataType: Type of the data (e.g., "str", "int", "time").
32        :param dataFormat: Used if dataType is "time" (e.g. "HH:MM AM/PM").
33        :param applyFormat: Whether to apply the dataFormat for display.
34        """
35        self.id = id
36        self.header = header
37        self.width = width
38        self.align = align
39        self.hidden = hidden
40        self.css = css
41        self.dataType = dataType
42        self.dataFormat = dataFormat
43        self.applyFormat = applyFormat
44        self.coltype = coltype
45
46    def to_dict(self) -> Dict[str, Any]:
47        config_dict = {
48            "id": self.id,
49            "header": self.header,
50            "width": self.width,
51            "align": self.align,
52            "hidden": self.hidden,
53            "css": self.css,
54            "dataType": self.dataType,
55            "dataFormat": self.dataFormat,
56            "applyFormat": self.applyFormat,
57            "type": self.coltype
58        }
59        # Remove keys that are None so we don't pass unnecessary data to JS
60        return {k: v for k, v in config_dict.items() if v is not None}

Configuration class for CardFlow columns. Similar to GridColumnConfig, lets you control properties like width, header text, etc.

CardFlowColumnConfig( id: str, header: Union[str, Dict[str, Any]], width: Union[int, str] = '100px', align: str = None, hidden: bool = False, css: str = None, dataType: str = 'str', dataFormat: str = '', applyFormat: bool = False, coltype: str = '')
 9    def __init__(
10        self,
11        id: str,
12        header: Union[str, Dict[str, Any]],
13        width: Union[int, str] = "100px",
14        align: str = None,
15        hidden: bool = False,
16        css: str = None,
17        dataType: str = "str",
18        dataFormat: str = "",
19        applyFormat: bool = False,
20        coltype: str = ""
21    ):
22        """
23        Initializes a CardFlow column configuration.
24        
25        :param id: Unique identifier for the column.
26        :param header: Header text or a more complex header config.
27        :param width: Column width (e.g., "100px" or 100).
28        :param align: Alignment for cell content.
29        :param hidden: Whether the column is hidden.
30        :param css: Additional CSS classes.
31        :param dataType: Type of the data (e.g., "str", "int", "time").
32        :param dataFormat: Used if dataType is "time" (e.g. "HH:MM AM/PM").
33        :param applyFormat: Whether to apply the dataFormat for display.
34        """
35        self.id = id
36        self.header = header
37        self.width = width
38        self.align = align
39        self.hidden = hidden
40        self.css = css
41        self.dataType = dataType
42        self.dataFormat = dataFormat
43        self.applyFormat = applyFormat
44        self.coltype = coltype

Initializes a CardFlow column configuration.

Parameters
  • id: Unique identifier for the column.
  • header: Header text or a more complex header config.
  • width: Column width (e.g., "100px" or 100).
  • align: Alignment for cell content.
  • hidden: Whether the column is hidden.
  • css: Additional CSS classes.
  • dataType: Type of the data (e.g., "str", "int", "time").
  • dataFormat: Used if dataType is "time" (e.g. "HH: MM AM/PM").
  • applyFormat: Whether to apply the dataFormat for display.
id
header
width
align
hidden
css
dataType
dataFormat
applyFormat
coltype
def to_dict(self) -> Dict[str, Any]:
46    def to_dict(self) -> Dict[str, Any]:
47        config_dict = {
48            "id": self.id,
49            "header": self.header,
50            "width": self.width,
51            "align": self.align,
52            "hidden": self.hidden,
53            "css": self.css,
54            "dataType": self.dataType,
55            "dataFormat": self.dataFormat,
56            "applyFormat": self.applyFormat,
57            "type": self.coltype
58        }
59        # Remove keys that are None so we don't pass unnecessary data to JS
60        return {k: v for k, v in config_dict.items() if v is not None}