dhxpyt.grid

1from .grid import Grid
2from .grid_config import GridConfig, GridColumnConfig
3
4__all__ = ["Grid", "GridConfig", "GridColumnConfig"]
class Grid:
 14class Grid:
 15    def __init__(self, config: GridConfig = None, widget_parent: str = None):
 16        """
 17        Initializes the Grid widget.
 18
 19        :param config: (Optional) The GridConfig object containing the grid configuration.
 20        :param widget_parent: (Optional) The ID of the HTML element where the grid will be attached.
 21        """
 22        if config is None:
 23            config = GridConfig()
 24        config_dict = config.to_dict()
 25        self.grid = js.dhx.Grid.new(widget_parent, js.JSON.parse(json.dumps(config_dict)))
 26
 27    """ Grid API Functions """
 28
 29    def add_cell_css(self, row_id: Union[str, int], col_id: Union[str, int], css: str) -> None:
 30        """Adds a CSS class to a cell."""
 31        self.grid.addCellCss(row_id, col_id, css)
 32
 33    def add_row_css(self, row_id: Union[str, int], css: str) -> None:
 34        """Adds a CSS class to a row."""
 35        self.grid.addRowCss(row_id, css)
 36
 37    def add_span(self, span_obj: Dict[str, Any]) -> None:
 38        """Adds a span to the grid."""
 39        self.grid.addSpan(js.JSON.parse(json.dumps(span_obj)))
 40
 41    def adjust_column_width(self, col_id: Union[str, int], adjust: Union[str, bool] = None) -> None:
 42        """Adjusts the width of a column."""
 43        self.grid.adjustColumnWidth(col_id, adjust)
 44
 45    def destructor(self) -> None:
 46        """Destroys the grid instance and releases resources."""
 47        self.grid.destructor()
 48
 49    def edit_cell(self, row_id: Union[str, int], col_id: Union[str, int], editor_type: str = None) -> None:
 50        """Enables editing of a grid cell."""
 51        self.grid.editCell(row_id, col_id, editor_type)
 52
 53    def edit_end(self, without_save: bool = False) -> None:
 54        """Finishes editing in a cell."""
 55        self.grid.editEnd(without_save)
 56
 57    def get_cell_rect(self, row_id: Union[str, int], col_id: Union[str, int]) -> Dict[str, Any]:
 58        """Returns the parameters of a cell."""
 59        rect = self.grid.getCellRect(row_id, col_id)
 60        return rect.to_py()
 61
 62    def get_column(self, col_id: Union[str, int]) -> Dict[str, Any]:
 63        """Returns an object with attributes of a column."""
 64        column = self.grid.getColumn(col_id)
 65        return column.to_py()
 66
 67    def get_header_filter(self, col_id: Union[str, int]) -> Any:
 68        """Returns an object with methods for the header filter of the specified column."""
 69        return self.grid.getHeaderFilter(col_id)
 70
 71    def get_scroll_state(self) -> Dict[str, int]:
 72        """Returns the coordinates of the scroll position."""
 73        state = self.grid.getScrollState()
 74        return state.to_py()
 75
 76    def get_sorting_state(self) -> Dict[str, Any]:
 77        """Returns the current state of sorting data in the grid."""
 78        state = self.grid.getSortingState()
 79        return state.to_py()
 80
 81    def get_span(self, row_id: Union[str, int], col_id: Union[str, int]) -> Dict[str, Any]:
 82        """Returns an object with spans."""
 83        span = self.grid.getSpan(row_id, col_id)
 84        return span.to_py()
 85
 86    def hide_column(self, col_id: Union[str, int]) -> None:
 87        """Hides a column of the grid."""
 88        self.grid.hideColumn(col_id)
 89
 90    def hide_row(self, row_id: Union[str, int]) -> None:
 91        """Hides a row of the grid."""
 92        self.grid.hideRow(row_id)
 93
 94    def is_column_hidden(self, col_id: Union[str, int]) -> bool:
 95        """Checks whether a column is hidden."""
 96        return self.grid.isColumnHidden(col_id)
 97
 98    def is_row_hidden(self, row_id: Union[str, int]) -> bool:
 99        """Checks whether a row is hidden."""
100        return self.grid.isRowHidden(row_id)
101
102    def paint(self) -> None:
103        """Repaints the grid on the page."""
104        self.grid.paint()
105
106    def remove_cell_css(self, row_id: Union[str, int], col_id: Union[str, int], css: str) -> None:
107        """Removes a CSS class from a cell."""
108        self.grid.removeCellCss(row_id, col_id, css)
109
110    def remove_row_css(self, row_id: Union[str, int], css: str) -> None:
111        """Removes a CSS class from a row."""
112        self.grid.removeRowCss(row_id, css)
113
114    def remove_span(self, row_id: Union[str, int], col_id: Union[str, int]) -> None:
115        """Removes a span from the grid."""
116        self.grid.removeSpan(row_id, col_id)
117
118    def scroll(self, x: int = None, y: int = None) -> None:
119        """Scrolls the grid to the specified coordinates."""
120        self.grid.scroll(x, y)
121
122    def scroll_to(self, row_id: Union[str, int], col_id: Union[str, int]) -> None:
123        """Scrolls the grid to a specified cell."""
124        self.grid.scrollTo(row_id, col_id)
125
126    def set_columns(self, columns: List[Dict[str, Any]]) -> None:
127        """Sets configuration for grid columns."""
128        self.grid.setColumns(js.JSON.parse(json.dumps(columns)))
129
130    def show_column(self, col_id: Union[str, int]) -> None:
131        """Shows a hidden column."""
132        self.grid.showColumn(col_id)
133
134    def show_row(self, row_id: Union[str, int]) -> None:
135        """Shows a hidden row."""
136        self.grid.showRow(row_id)
137
138    """ Grid Event Handlers """
139
140    def add_event_handler(self, event_name: str, handler: Callable) -> None:
141        """Adds an event handler for the specified event."""
142        event_proxy = create_proxy(handler)
143        self.grid.events.on(event_name, event_proxy)
144
145    # Example event: afterEditEnd
146    def on_after_edit_end(self, handler: Callable[[Any, Dict[str, Any], Dict[str, Any]], None]) -> None:
147        """Fires after editing of a cell is ended."""
148        def event_handler(value, row, column):
149            handler(value, row.to_py(), column.to_py())
150        self.grid.events.on('afterEditEnd', create_proxy(event_handler))
151
152    def on_cell_click(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
153        """Fires when a cell is clicked."""
154        def event_handler(row, column, event):
155            handler(row.to_py(), column.to_py(), event)
156        self.grid.events.on('cellClick', create_proxy(event_handler))
157
158    def on_cell_dbl_click(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
159        """Fires when a cell is double-clicked."""
160        def event_handler(row, column, event):
161            handler(row.to_py(), column.to_py(), event)
162        self.grid.events.on('cellDblClick', create_proxy(event_handler))
163
164    def on_cell_mouse_down(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
165        """Fires before releasing the left mouse button when clicking on a grid cell."""
166        def event_handler(row, column, event):
167            handler(row.to_py(), column.to_py(), event)
168        self.grid.events.on('cellMouseDown', create_proxy(event_handler))
169
170    def on_cell_mouse_over(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
171        """Fires on moving the mouse pointer over a grid cell."""
172        def event_handler(row, column, event):
173            handler(row.to_py(), column.to_py(), event)
174        self.grid.events.on('cellMouseOver', create_proxy(event_handler))
175
176    def on_cell_right_click(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
177        """Fires on right click on a grid cell."""
178        def event_handler(row, column, event):
179            handler(row.to_py(), column.to_py(), event)
180        self.grid.events.on('cellRightClick', create_proxy(event_handler))
181
182    """ Grid Drag-and-Drop Event Handlers """
183
184    def on_before_row_drag(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
185        """Fires before dragging a row starts."""
186        def event_handler(data, event):
187            handler(data.to_py(), event)
188        self.grid.events.on('beforeRowDrag', create_proxy(event_handler))
189
190    def on_after_row_drag(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
191        """Fires after dragging a row finishes."""
192        def event_handler(data, event):
193            handler(data.to_py(), event)
194        self.grid.events.on('afterRowDrag', create_proxy(event_handler))
195
196    def on_before_column_drag(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
197        """Fires before dragging a column starts."""
198        def event_handler(data, event):
199            handler(data.to_py(), event)
200        self.grid.events.on('beforeColumnDrag', create_proxy(event_handler))
201
202    def on_after_column_drag(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
203        """Fires after dragging a column finishes."""
204        def event_handler(data, event):
205            handler(data.to_py(), event)
206        self.grid.events.on('afterColumnDrag', create_proxy(event_handler))
207
208    def on_row_drop(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
209        """Fires when a row is dropped."""
210        def event_handler(data, event):
211            handler(data.to_py(), event)
212        self.grid.events.on('afterRowDrop', create_proxy(event_handler))
213
214    def on_column_drop(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
215        """Fires when a column is dropped."""
216        def event_handler(data, event):
217            handler(data.to_py(), event)
218        self.grid.events.on('afterColumnDrop', create_proxy(event_handler))
219
220    # Dragging callbacks
221    def on_drag_row_in(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
222        """Fires when a row is dragged over a potential target."""
223        def event_handler(data, event):
224            handler(data.to_py(), event)
225        self.grid.events.on('dragRowIn', create_proxy(event_handler))
226
227    def on_drag_row_out(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
228        """Fires when a row is dragged out of a potential target."""
229        def event_handler(data, event):
230            handler(data.to_py(), event)
231        self.grid.events.on('dragRowOut', create_proxy(event_handler))
232
233    def on_drag_column_in(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
234        """Fires when a column is dragged over a potential target."""
235        def event_handler(data, event):
236            handler(data.to_py(), event)
237        self.grid.events.on('dragColumnIn', create_proxy(event_handler))
238
239    def on_drag_column_out(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
240        """Fires when a column is dragged out of a potential target."""
241        def event_handler(data, event):
242            handler(data.to_py(), event)
243        self.grid.events.on('dragColumnOut', create_proxy(event_handler))
244
245    def on_drag_row_start(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
246        """Fires when the dragging of a row starts."""
247        def event_handler(data, event):
248            handler(data.to_py(), event)
249        self.grid.events.on('dragRowStart', create_proxy(event_handler))
250
251    def on_drag_column_start(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
252        """Fires when the dragging of a column starts."""
253        def event_handler(data, event):
254            handler(data.to_py(), event)
255        self.grid.events.on('dragColumnStart', create_proxy(event_handler))
256
257    # Similarly, other events can be added following the documentation provided.
258
259    """ Grid Selection Functions """
260
261    def select_cell(self, row: Union[Dict[str, Any], str, int] = None, column: Union[Dict[str, Any], str, int] = None,
262                    ctrl_up: bool = False, shift_up: bool = False) -> None:
263        """Sets selection to specified cells."""
264        self.grid.selection.setCell(row, column, ctrl_up, shift_up)
265
266    def get_selected_cells(self) -> List[Dict[str, Any]]:
267        """Returns an array with config objects of selected cells."""
268        cells = self.grid.selection.getCells()
269        return [cell.to_py() for cell in cells]
270
271    def unselect_cell(self, row_id: Union[str, int] = None, col_id: Union[str, int] = None) -> None:
272        """Unselects previously selected cells."""
273        self.grid.selection.removeCell(row_id, col_id)
274
275    """ Grid Export Functions """
276
277    def export_to_csv(self, config: Dict[str, Any] = None) -> str:
278        """Exports data from the grid into a CSV string or file."""
279        if config is None:
280            config = {}
281        result = self.grid.csv(js.JSON.parse(json.dumps(config)))
282        return result
283
284    def export_to_pdf(self, config: Dict[str, Any] = None) -> None:
285        """Exports data from the grid to a PDF file."""
286        if config is None:
287            config = {}
288        self.grid.pdf(js.JSON.parse(json.dumps(config)))
289
290    def export_to_png(self, config: Dict[str, Any] = None) -> None:
291        """Exports data from the grid to a PNG file."""
292        if config is None:
293            config = {}
294        self.grid.png(js.JSON.parse(json.dumps(config)))
295
296    def export_to_xlsx(self, config: Dict[str, Any] = None) -> None:
297        """Exports data from the grid to an Excel file."""
298        if config is None:
299            config = {}
300        self.grid.xlsx(js.JSON.parse(json.dumps(config)))
Grid( config: GridConfig = None, widget_parent: str = None)
15    def __init__(self, config: GridConfig = None, widget_parent: str = None):
16        """
17        Initializes the Grid widget.
18
19        :param config: (Optional) The GridConfig object containing the grid configuration.
20        :param widget_parent: (Optional) The ID of the HTML element where the grid will be attached.
21        """
22        if config is None:
23            config = GridConfig()
24        config_dict = config.to_dict()
25        self.grid = js.dhx.Grid.new(widget_parent, js.JSON.parse(json.dumps(config_dict)))

Initializes the Grid widget.

Parameters
  • config: (Optional) The GridConfig object containing the grid configuration.
  • widget_parent: (Optional) The ID of the HTML element where the grid will be attached.
grid

Grid API Functions

def add_cell_css(self, row_id: Union[str, int], col_id: Union[str, int], css: str) -> None:
29    def add_cell_css(self, row_id: Union[str, int], col_id: Union[str, int], css: str) -> None:
30        """Adds a CSS class to a cell."""
31        self.grid.addCellCss(row_id, col_id, css)

Adds a CSS class to a cell.

def add_row_css(self, row_id: Union[str, int], css: str) -> None:
33    def add_row_css(self, row_id: Union[str, int], css: str) -> None:
34        """Adds a CSS class to a row."""
35        self.grid.addRowCss(row_id, css)

Adds a CSS class to a row.

def add_span(self, span_obj: Dict[str, Any]) -> None:
37    def add_span(self, span_obj: Dict[str, Any]) -> None:
38        """Adds a span to the grid."""
39        self.grid.addSpan(js.JSON.parse(json.dumps(span_obj)))

Adds a span to the grid.

def adjust_column_width(self, col_id: Union[str, int], adjust: Union[str, bool] = None) -> None:
41    def adjust_column_width(self, col_id: Union[str, int], adjust: Union[str, bool] = None) -> None:
42        """Adjusts the width of a column."""
43        self.grid.adjustColumnWidth(col_id, adjust)

Adjusts the width of a column.

def destructor(self) -> None:
45    def destructor(self) -> None:
46        """Destroys the grid instance and releases resources."""
47        self.grid.destructor()

Destroys the grid instance and releases resources.

def edit_cell( self, row_id: Union[str, int], col_id: Union[str, int], editor_type: str = None) -> None:
49    def edit_cell(self, row_id: Union[str, int], col_id: Union[str, int], editor_type: str = None) -> None:
50        """Enables editing of a grid cell."""
51        self.grid.editCell(row_id, col_id, editor_type)

Enables editing of a grid cell.

def edit_end(self, without_save: bool = False) -> None:
53    def edit_end(self, without_save: bool = False) -> None:
54        """Finishes editing in a cell."""
55        self.grid.editEnd(without_save)

Finishes editing in a cell.

def get_cell_rect(self, row_id: Union[str, int], col_id: Union[str, int]) -> Dict[str, Any]:
57    def get_cell_rect(self, row_id: Union[str, int], col_id: Union[str, int]) -> Dict[str, Any]:
58        """Returns the parameters of a cell."""
59        rect = self.grid.getCellRect(row_id, col_id)
60        return rect.to_py()

Returns the parameters of a cell.

def get_column(self, col_id: Union[str, int]) -> Dict[str, Any]:
62    def get_column(self, col_id: Union[str, int]) -> Dict[str, Any]:
63        """Returns an object with attributes of a column."""
64        column = self.grid.getColumn(col_id)
65        return column.to_py()

Returns an object with attributes of a column.

def get_header_filter(self, col_id: Union[str, int]) -> Any:
67    def get_header_filter(self, col_id: Union[str, int]) -> Any:
68        """Returns an object with methods for the header filter of the specified column."""
69        return self.grid.getHeaderFilter(col_id)

Returns an object with methods for the header filter of the specified column.

def get_scroll_state(self) -> Dict[str, int]:
71    def get_scroll_state(self) -> Dict[str, int]:
72        """Returns the coordinates of the scroll position."""
73        state = self.grid.getScrollState()
74        return state.to_py()

Returns the coordinates of the scroll position.

def get_sorting_state(self) -> Dict[str, Any]:
76    def get_sorting_state(self) -> Dict[str, Any]:
77        """Returns the current state of sorting data in the grid."""
78        state = self.grid.getSortingState()
79        return state.to_py()

Returns the current state of sorting data in the grid.

def get_span(self, row_id: Union[str, int], col_id: Union[str, int]) -> Dict[str, Any]:
81    def get_span(self, row_id: Union[str, int], col_id: Union[str, int]) -> Dict[str, Any]:
82        """Returns an object with spans."""
83        span = self.grid.getSpan(row_id, col_id)
84        return span.to_py()

Returns an object with spans.

def hide_column(self, col_id: Union[str, int]) -> None:
86    def hide_column(self, col_id: Union[str, int]) -> None:
87        """Hides a column of the grid."""
88        self.grid.hideColumn(col_id)

Hides a column of the grid.

def hide_row(self, row_id: Union[str, int]) -> None:
90    def hide_row(self, row_id: Union[str, int]) -> None:
91        """Hides a row of the grid."""
92        self.grid.hideRow(row_id)

Hides a row of the grid.

def is_column_hidden(self, col_id: Union[str, int]) -> bool:
94    def is_column_hidden(self, col_id: Union[str, int]) -> bool:
95        """Checks whether a column is hidden."""
96        return self.grid.isColumnHidden(col_id)

Checks whether a column is hidden.

def is_row_hidden(self, row_id: Union[str, int]) -> bool:
 98    def is_row_hidden(self, row_id: Union[str, int]) -> bool:
 99        """Checks whether a row is hidden."""
100        return self.grid.isRowHidden(row_id)

Checks whether a row is hidden.

def paint(self) -> None:
102    def paint(self) -> None:
103        """Repaints the grid on the page."""
104        self.grid.paint()

Repaints the grid on the page.

def remove_cell_css(self, row_id: Union[str, int], col_id: Union[str, int], css: str) -> None:
106    def remove_cell_css(self, row_id: Union[str, int], col_id: Union[str, int], css: str) -> None:
107        """Removes a CSS class from a cell."""
108        self.grid.removeCellCss(row_id, col_id, css)

Removes a CSS class from a cell.

def remove_row_css(self, row_id: Union[str, int], css: str) -> None:
110    def remove_row_css(self, row_id: Union[str, int], css: str) -> None:
111        """Removes a CSS class from a row."""
112        self.grid.removeRowCss(row_id, css)

Removes a CSS class from a row.

def remove_span(self, row_id: Union[str, int], col_id: Union[str, int]) -> None:
114    def remove_span(self, row_id: Union[str, int], col_id: Union[str, int]) -> None:
115        """Removes a span from the grid."""
116        self.grid.removeSpan(row_id, col_id)

Removes a span from the grid.

def scroll(self, x: int = None, y: int = None) -> None:
118    def scroll(self, x: int = None, y: int = None) -> None:
119        """Scrolls the grid to the specified coordinates."""
120        self.grid.scroll(x, y)

Scrolls the grid to the specified coordinates.

def scroll_to(self, row_id: Union[str, int], col_id: Union[str, int]) -> None:
122    def scroll_to(self, row_id: Union[str, int], col_id: Union[str, int]) -> None:
123        """Scrolls the grid to a specified cell."""
124        self.grid.scrollTo(row_id, col_id)

Scrolls the grid to a specified cell.

def set_columns(self, columns: List[Dict[str, Any]]) -> None:
126    def set_columns(self, columns: List[Dict[str, Any]]) -> None:
127        """Sets configuration for grid columns."""
128        self.grid.setColumns(js.JSON.parse(json.dumps(columns)))

Sets configuration for grid columns.

def show_column(self, col_id: Union[str, int]) -> None:
130    def show_column(self, col_id: Union[str, int]) -> None:
131        """Shows a hidden column."""
132        self.grid.showColumn(col_id)

Shows a hidden column.

def show_row(self, row_id: Union[str, int]) -> None:
134    def show_row(self, row_id: Union[str, int]) -> None:
135        """Shows a hidden row."""
136        self.grid.showRow(row_id)

Shows a hidden row.

def add_event_handler(self, event_name: str, handler: Callable) -> None:
140    def add_event_handler(self, event_name: str, handler: Callable) -> None:
141        """Adds an event handler for the specified event."""
142        event_proxy = create_proxy(handler)
143        self.grid.events.on(event_name, event_proxy)

Adds an event handler for the specified event.

def on_after_edit_end( self, handler: Callable[[Any, Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
146    def on_after_edit_end(self, handler: Callable[[Any, Dict[str, Any], Dict[str, Any]], None]) -> None:
147        """Fires after editing of a cell is ended."""
148        def event_handler(value, row, column):
149            handler(value, row.to_py(), column.to_py())
150        self.grid.events.on('afterEditEnd', create_proxy(event_handler))

Fires after editing of a cell is ended.

def on_cell_click( self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], NoneType]) -> None:
152    def on_cell_click(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
153        """Fires when a cell is clicked."""
154        def event_handler(row, column, event):
155            handler(row.to_py(), column.to_py(), event)
156        self.grid.events.on('cellClick', create_proxy(event_handler))

Fires when a cell is clicked.

def on_cell_dbl_click( self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], NoneType]) -> None:
158    def on_cell_dbl_click(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
159        """Fires when a cell is double-clicked."""
160        def event_handler(row, column, event):
161            handler(row.to_py(), column.to_py(), event)
162        self.grid.events.on('cellDblClick', create_proxy(event_handler))

Fires when a cell is double-clicked.

def on_cell_mouse_down( self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], NoneType]) -> None:
164    def on_cell_mouse_down(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
165        """Fires before releasing the left mouse button when clicking on a grid cell."""
166        def event_handler(row, column, event):
167            handler(row.to_py(), column.to_py(), event)
168        self.grid.events.on('cellMouseDown', create_proxy(event_handler))

Fires before releasing the left mouse button when clicking on a grid cell.

def on_cell_mouse_over( self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], NoneType]) -> None:
170    def on_cell_mouse_over(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
171        """Fires on moving the mouse pointer over a grid cell."""
172        def event_handler(row, column, event):
173            handler(row.to_py(), column.to_py(), event)
174        self.grid.events.on('cellMouseOver', create_proxy(event_handler))

Fires on moving the mouse pointer over a grid cell.

def on_cell_right_click( self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], NoneType]) -> None:
176    def on_cell_right_click(self, handler: Callable[[Dict[str, Any], Dict[str, Any], Any], None]) -> None:
177        """Fires on right click on a grid cell."""
178        def event_handler(row, column, event):
179            handler(row.to_py(), column.to_py(), event)
180        self.grid.events.on('cellRightClick', create_proxy(event_handler))

Fires on right click on a grid cell.

def on_before_row_drag( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
184    def on_before_row_drag(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
185        """Fires before dragging a row starts."""
186        def event_handler(data, event):
187            handler(data.to_py(), event)
188        self.grid.events.on('beforeRowDrag', create_proxy(event_handler))

Fires before dragging a row starts.

def on_after_row_drag( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
190    def on_after_row_drag(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
191        """Fires after dragging a row finishes."""
192        def event_handler(data, event):
193            handler(data.to_py(), event)
194        self.grid.events.on('afterRowDrag', create_proxy(event_handler))

Fires after dragging a row finishes.

def on_before_column_drag( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
196    def on_before_column_drag(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
197        """Fires before dragging a column starts."""
198        def event_handler(data, event):
199            handler(data.to_py(), event)
200        self.grid.events.on('beforeColumnDrag', create_proxy(event_handler))

Fires before dragging a column starts.

def on_after_column_drag( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
202    def on_after_column_drag(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
203        """Fires after dragging a column finishes."""
204        def event_handler(data, event):
205            handler(data.to_py(), event)
206        self.grid.events.on('afterColumnDrag', create_proxy(event_handler))

Fires after dragging a column finishes.

def on_row_drop( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
208    def on_row_drop(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
209        """Fires when a row is dropped."""
210        def event_handler(data, event):
211            handler(data.to_py(), event)
212        self.grid.events.on('afterRowDrop', create_proxy(event_handler))

Fires when a row is dropped.

def on_column_drop( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
214    def on_column_drop(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
215        """Fires when a column is dropped."""
216        def event_handler(data, event):
217            handler(data.to_py(), event)
218        self.grid.events.on('afterColumnDrop', create_proxy(event_handler))

Fires when a column is dropped.

def on_drag_row_in( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
221    def on_drag_row_in(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
222        """Fires when a row is dragged over a potential target."""
223        def event_handler(data, event):
224            handler(data.to_py(), event)
225        self.grid.events.on('dragRowIn', create_proxy(event_handler))

Fires when a row is dragged over a potential target.

def on_drag_row_out( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
227    def on_drag_row_out(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
228        """Fires when a row is dragged out of a potential target."""
229        def event_handler(data, event):
230            handler(data.to_py(), event)
231        self.grid.events.on('dragRowOut', create_proxy(event_handler))

Fires when a row is dragged out of a potential target.

def on_drag_column_in( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
233    def on_drag_column_in(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
234        """Fires when a column is dragged over a potential target."""
235        def event_handler(data, event):
236            handler(data.to_py(), event)
237        self.grid.events.on('dragColumnIn', create_proxy(event_handler))

Fires when a column is dragged over a potential target.

def on_drag_column_out( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
239    def on_drag_column_out(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
240        """Fires when a column is dragged out of a potential target."""
241        def event_handler(data, event):
242            handler(data.to_py(), event)
243        self.grid.events.on('dragColumnOut', create_proxy(event_handler))

Fires when a column is dragged out of a potential target.

def on_drag_row_start( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
245    def on_drag_row_start(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
246        """Fires when the dragging of a row starts."""
247        def event_handler(data, event):
248            handler(data.to_py(), event)
249        self.grid.events.on('dragRowStart', create_proxy(event_handler))

Fires when the dragging of a row starts.

def on_drag_column_start( self, handler: Callable[[Dict[str, Any], Dict[str, Any]], NoneType]) -> None:
251    def on_drag_column_start(self, handler: Callable[[Dict[str, Any], Dict[str, Any]], None]) -> None:
252        """Fires when the dragging of a column starts."""
253        def event_handler(data, event):
254            handler(data.to_py(), event)
255        self.grid.events.on('dragColumnStart', create_proxy(event_handler))

Fires when the dragging of a column starts.

def select_cell( self, row: Union[Dict[str, Any], str, int] = None, column: Union[Dict[str, Any], str, int] = None, ctrl_up: bool = False, shift_up: bool = False) -> None:
261    def select_cell(self, row: Union[Dict[str, Any], str, int] = None, column: Union[Dict[str, Any], str, int] = None,
262                    ctrl_up: bool = False, shift_up: bool = False) -> None:
263        """Sets selection to specified cells."""
264        self.grid.selection.setCell(row, column, ctrl_up, shift_up)

Sets selection to specified cells.

def get_selected_cells(self) -> List[Dict[str, Any]]:
266    def get_selected_cells(self) -> List[Dict[str, Any]]:
267        """Returns an array with config objects of selected cells."""
268        cells = self.grid.selection.getCells()
269        return [cell.to_py() for cell in cells]

Returns an array with config objects of selected cells.

def unselect_cell( self, row_id: Union[str, int] = None, col_id: Union[str, int] = None) -> None:
271    def unselect_cell(self, row_id: Union[str, int] = None, col_id: Union[str, int] = None) -> None:
272        """Unselects previously selected cells."""
273        self.grid.selection.removeCell(row_id, col_id)

Unselects previously selected cells.

def export_to_csv(self, config: Dict[str, Any] = None) -> str:
277    def export_to_csv(self, config: Dict[str, Any] = None) -> str:
278        """Exports data from the grid into a CSV string or file."""
279        if config is None:
280            config = {}
281        result = self.grid.csv(js.JSON.parse(json.dumps(config)))
282        return result

Exports data from the grid into a CSV string or file.

def export_to_pdf(self, config: Dict[str, Any] = None) -> None:
284    def export_to_pdf(self, config: Dict[str, Any] = None) -> None:
285        """Exports data from the grid to a PDF file."""
286        if config is None:
287            config = {}
288        self.grid.pdf(js.JSON.parse(json.dumps(config)))

Exports data from the grid to a PDF file.

def export_to_png(self, config: Dict[str, Any] = None) -> None:
290    def export_to_png(self, config: Dict[str, Any] = None) -> None:
291        """Exports data from the grid to a PNG file."""
292        if config is None:
293            config = {}
294        self.grid.png(js.JSON.parse(json.dumps(config)))

Exports data from the grid to a PNG file.

def export_to_xlsx(self, config: Dict[str, Any] = None) -> None:
296    def export_to_xlsx(self, config: Dict[str, Any] = None) -> None:
297        """Exports data from the grid to an Excel file."""
298        if config is None:
299            config = {}
300        self.grid.xlsx(js.JSON.parse(json.dumps(config)))

Exports data from the grid to an Excel file.

class GridConfig:
 96class GridConfig:
 97    """
 98    Configuration class for the Grid widget.
 99    """
100    def __init__(self,
101                 columns: List[GridColumnConfig],
102                 data: List[Dict[str, Any]] = None,
103                 adjust: Union[str, bool] = False,
104                 autoEmptyRow: bool = False,
105                 autoHeight: bool = False,
106                 autoWidth: bool = False,
107                 bottomSplit: int = None,
108                 collapsed: bool = False,
109                 css: str = None,
110                 type: str = None,
111                 dragCopy: bool = None,
112                 dragItem: str = None,
113                 dragMode: str = None,
114                 editable: bool = False,
115                 eventHandlers: Dict[str, Any] = None,
116                 exportStyles: Union[bool, List[str]] = False,
117                 footerAutoHeight: bool = False,
118                 footerRowHeight: int = 0,
119                 footerTooltip: Union[bool, Dict[str, Any]] = True,
120                 headerAutoHeight: bool = False,
121                 headerRowHeight: int = 40,
122                 headerTooltip: Union[bool, Dict[str, Any]] = True,
123                 height: Union[int, str] = None,
124                 htmlEnable: bool = False,
125                 keyNavigation: bool = True,
126                 leftSplit: int = None,
127                 multiselection: bool = False,
128                 resizable: bool = False,
129                 rightSplit: int = None,
130                 rowCss: Callable[[Dict[str, Any]], str] = None,
131                 rowHeight: int = 40,
132                 selection: Union[bool, str] = False,
133                 sortable: bool = True,
134                 spans: List[Dict[str, Any]] = None,
135                 tooltip: Union[bool, Dict[str, Any]] = True,
136                 topSplit: int = None,
137                 width: int = None):
138        """
139        Initializes the GridConfig.
140
141        :param columns: (Required) List of column configurations.
142        :param data: (Optional) List of data objects.
143        :param adjust: (Optional) Auto adjust columns.
144        :param autoEmptyRow: (Optional) Adds an empty row after the last filled row.
145        :param autoHeight: (Optional) Makes long text split into multiple lines.
146        :param autoWidth: (Optional) Makes grid's columns fit the size of the grid.
147        :param bottomSplit: (Optional) Number of frozen rows from the bottom.
148        :param css: (Optional) Adds style classes to Grid.
149        :param dragCopy: (Optional) Defines whether a row is copied during drag-n-drop.
150        :param dragItem: (Optional) Enables reordering columns or rows by drag and drop.
151        :param dragMode: (Optional) Enables drag-n-drop in Grid.
152        :param editable: (Optional) Enables editing in Grid columns.
153        :param eventHandlers: (Optional) Adds event handlers to HTML elements in the grid.
154        :param exportStyles: (Optional) Defines the styles to be sent when exporting.
155        :param footerAutoHeight: (Optional) Allows adjusting the footer height.
156        :param footerRowHeight: (Optional) Sets the height of rows in the footer.
157        :param footerTooltip: (Optional) Controls the footer tooltips.
158        :param headerAutoHeight: (Optional) Allows adjusting the header height.
159        :param headerRowHeight: (Optional) Sets the height of rows in the header.
160        :param headerTooltip: (Optional) Controls the header tooltips.
161        :param height: (Optional) Sets the height of the grid.
162        :param htmlEnable: (Optional) Specifies the HTML content of Grid columns.
163        :param keyNavigation: (Optional) Enables keyboard navigation in Grid.
164        :param leftSplit: (Optional) Number of frozen columns from the left.
165        :param multiselection: (Optional) Enables multi-row/multi-cell selection.
166        :param resizable: (Optional) Defines whether columns can be resized.
167        :param rightSplit: (Optional) Number of frozen columns from the right.
168        :param rowCss: (Optional) Sets style for a row.
169        :param rowHeight: (Optional) Defines the height of a row.
170        :param selection: (Optional) Enables selection in the grid.
171        :param sortable: (Optional) Defines whether sorting is enabled.
172        :param spans: (Optional) Describes the configuration of spans.
173        :param tooltip: (Optional) Enables/disables all the tooltips of a column.
174        :param topSplit: (Optional) Number of frozen rows from the top.
175        :param width: (Optional) Sets the width of the grid.
176        """
177        self.columns = columns
178        self.data = data
179        self.adjust = adjust
180        self.autoEmptyRow = autoEmptyRow
181        self.autoHeight = autoHeight
182        self.autoWidth = autoWidth
183        self.bottomSplit = bottomSplit
184        self.css = css
185        self.collapsed= collapsed
186        self.type = type
187        self.dragCopy = dragCopy
188        self.dragItem = dragItem
189        self.dragMode = dragMode
190        self.editable = editable
191        self.eventHandlers = eventHandlers
192        self.exportStyles = exportStyles
193        self.footerAutoHeight = footerAutoHeight
194        self.footerRowHeight = footerRowHeight
195        self.footerTooltip = footerTooltip
196        self.headerAutoHeight = headerAutoHeight
197        self.headerRowHeight = headerRowHeight
198        self.headerTooltip = headerTooltip
199        self.height = height
200        self.htmlEnable = htmlEnable
201        self.keyNavigation = keyNavigation
202        self.leftSplit = leftSplit
203        self.multiselection = multiselection
204        self.resizable = resizable
205        self.rightSplit = rightSplit
206        self.rowCss = rowCss
207        self.rowHeight = rowHeight
208        self.selection = selection
209        self.sortable = sortable
210        self.spans = spans
211        self.tooltip = tooltip
212        self.topSplit = topSplit
213        self.width = width
214
215    def to_dict(self) -> Dict[str, Any]:
216        """
217        Converts the GridConfig into a dictionary format.
218        """
219        config_dict = {
220            'columns': self.columns,
221            'data': self.data,
222            'adjust': self.adjust,
223            'autoEmptyRow': self.autoEmptyRow,
224            'autoHeight': self.autoHeight,
225            'autoWidth': self.autoWidth,
226            'bottomSplit': self.bottomSplit,
227            'css': self.css,
228            'type': self.type,
229            'dragCopy': self.dragCopy,
230            'dragItem': self.dragItem,
231            'dragMode': self.dragMode,
232            'editable': self.editable,
233            'eventHandlers': self.eventHandlers,
234            'exportStyles': self.exportStyles,
235            'footerAutoHeight': self.footerAutoHeight,
236            'footerRowHeight': self.footerRowHeight,
237            'footerTooltip': self.footerTooltip,
238            'headerAutoHeight': self.headerAutoHeight,
239            'headerRowHeight': self.headerRowHeight,
240            'headerTooltip': self.headerTooltip,
241            'height': self.height,
242            'htmlEnable': self.htmlEnable,
243            'keyNavigation': self.keyNavigation,
244            'leftSplit': self.leftSplit,
245            'multiselection': self.multiselection,
246            'resizable': self.resizable,
247            'rightSplit': self.rightSplit,
248            'rowCss': self.rowCss,
249            'rowHeight': self.rowHeight,
250            'selection': self.selection,
251            'sortable': self.sortable,
252            'spans': self.spans,
253            'tooltip': self.tooltip,
254            'topSplit': self.topSplit,
255            'width': self.width
256        }
257        # Remove None values
258        config_dict = {k: v for k, v in config_dict.items() if v is not None}
259
260        if self.columns:
261            config_dict['columns'] = [column.to_dict() for column in self.columns]
262
263        # Handle functions (e.g., rowCss)
264        if 'rowCss' in config_dict and callable(config_dict['rowCss']):
265            # Assuming rowCss is a JavaScript function
266            config_dict['rowCss'] = self.rowCss  # This may require further adaptation
267
268        return config_dict

Configuration class for the Grid widget.

GridConfig( columns: List[GridColumnConfig], data: List[Dict[str, Any]] = None, adjust: Union[str, bool] = False, autoEmptyRow: bool = False, autoHeight: bool = False, autoWidth: bool = False, bottomSplit: int = None, collapsed: bool = False, css: str = None, type: str = None, dragCopy: bool = None, dragItem: str = None, dragMode: str = None, editable: bool = False, eventHandlers: Dict[str, Any] = None, exportStyles: Union[bool, List[str]] = False, footerAutoHeight: bool = False, footerRowHeight: int = 0, footerTooltip: Union[bool, Dict[str, Any]] = True, headerAutoHeight: bool = False, headerRowHeight: int = 40, headerTooltip: Union[bool, Dict[str, Any]] = True, height: Union[int, str] = None, htmlEnable: bool = False, keyNavigation: bool = True, leftSplit: int = None, multiselection: bool = False, resizable: bool = False, rightSplit: int = None, rowCss: Callable[[Dict[str, Any]], str] = None, rowHeight: int = 40, selection: Union[bool, str] = False, sortable: bool = True, spans: List[Dict[str, Any]] = None, tooltip: Union[bool, Dict[str, Any]] = True, topSplit: int = None, width: int = None)
100    def __init__(self,
101                 columns: List[GridColumnConfig],
102                 data: List[Dict[str, Any]] = None,
103                 adjust: Union[str, bool] = False,
104                 autoEmptyRow: bool = False,
105                 autoHeight: bool = False,
106                 autoWidth: bool = False,
107                 bottomSplit: int = None,
108                 collapsed: bool = False,
109                 css: str = None,
110                 type: str = None,
111                 dragCopy: bool = None,
112                 dragItem: str = None,
113                 dragMode: str = None,
114                 editable: bool = False,
115                 eventHandlers: Dict[str, Any] = None,
116                 exportStyles: Union[bool, List[str]] = False,
117                 footerAutoHeight: bool = False,
118                 footerRowHeight: int = 0,
119                 footerTooltip: Union[bool, Dict[str, Any]] = True,
120                 headerAutoHeight: bool = False,
121                 headerRowHeight: int = 40,
122                 headerTooltip: Union[bool, Dict[str, Any]] = True,
123                 height: Union[int, str] = None,
124                 htmlEnable: bool = False,
125                 keyNavigation: bool = True,
126                 leftSplit: int = None,
127                 multiselection: bool = False,
128                 resizable: bool = False,
129                 rightSplit: int = None,
130                 rowCss: Callable[[Dict[str, Any]], str] = None,
131                 rowHeight: int = 40,
132                 selection: Union[bool, str] = False,
133                 sortable: bool = True,
134                 spans: List[Dict[str, Any]] = None,
135                 tooltip: Union[bool, Dict[str, Any]] = True,
136                 topSplit: int = None,
137                 width: int = None):
138        """
139        Initializes the GridConfig.
140
141        :param columns: (Required) List of column configurations.
142        :param data: (Optional) List of data objects.
143        :param adjust: (Optional) Auto adjust columns.
144        :param autoEmptyRow: (Optional) Adds an empty row after the last filled row.
145        :param autoHeight: (Optional) Makes long text split into multiple lines.
146        :param autoWidth: (Optional) Makes grid's columns fit the size of the grid.
147        :param bottomSplit: (Optional) Number of frozen rows from the bottom.
148        :param css: (Optional) Adds style classes to Grid.
149        :param dragCopy: (Optional) Defines whether a row is copied during drag-n-drop.
150        :param dragItem: (Optional) Enables reordering columns or rows by drag and drop.
151        :param dragMode: (Optional) Enables drag-n-drop in Grid.
152        :param editable: (Optional) Enables editing in Grid columns.
153        :param eventHandlers: (Optional) Adds event handlers to HTML elements in the grid.
154        :param exportStyles: (Optional) Defines the styles to be sent when exporting.
155        :param footerAutoHeight: (Optional) Allows adjusting the footer height.
156        :param footerRowHeight: (Optional) Sets the height of rows in the footer.
157        :param footerTooltip: (Optional) Controls the footer tooltips.
158        :param headerAutoHeight: (Optional) Allows adjusting the header height.
159        :param headerRowHeight: (Optional) Sets the height of rows in the header.
160        :param headerTooltip: (Optional) Controls the header tooltips.
161        :param height: (Optional) Sets the height of the grid.
162        :param htmlEnable: (Optional) Specifies the HTML content of Grid columns.
163        :param keyNavigation: (Optional) Enables keyboard navigation in Grid.
164        :param leftSplit: (Optional) Number of frozen columns from the left.
165        :param multiselection: (Optional) Enables multi-row/multi-cell selection.
166        :param resizable: (Optional) Defines whether columns can be resized.
167        :param rightSplit: (Optional) Number of frozen columns from the right.
168        :param rowCss: (Optional) Sets style for a row.
169        :param rowHeight: (Optional) Defines the height of a row.
170        :param selection: (Optional) Enables selection in the grid.
171        :param sortable: (Optional) Defines whether sorting is enabled.
172        :param spans: (Optional) Describes the configuration of spans.
173        :param tooltip: (Optional) Enables/disables all the tooltips of a column.
174        :param topSplit: (Optional) Number of frozen rows from the top.
175        :param width: (Optional) Sets the width of the grid.
176        """
177        self.columns = columns
178        self.data = data
179        self.adjust = adjust
180        self.autoEmptyRow = autoEmptyRow
181        self.autoHeight = autoHeight
182        self.autoWidth = autoWidth
183        self.bottomSplit = bottomSplit
184        self.css = css
185        self.collapsed= collapsed
186        self.type = type
187        self.dragCopy = dragCopy
188        self.dragItem = dragItem
189        self.dragMode = dragMode
190        self.editable = editable
191        self.eventHandlers = eventHandlers
192        self.exportStyles = exportStyles
193        self.footerAutoHeight = footerAutoHeight
194        self.footerRowHeight = footerRowHeight
195        self.footerTooltip = footerTooltip
196        self.headerAutoHeight = headerAutoHeight
197        self.headerRowHeight = headerRowHeight
198        self.headerTooltip = headerTooltip
199        self.height = height
200        self.htmlEnable = htmlEnable
201        self.keyNavigation = keyNavigation
202        self.leftSplit = leftSplit
203        self.multiselection = multiselection
204        self.resizable = resizable
205        self.rightSplit = rightSplit
206        self.rowCss = rowCss
207        self.rowHeight = rowHeight
208        self.selection = selection
209        self.sortable = sortable
210        self.spans = spans
211        self.tooltip = tooltip
212        self.topSplit = topSplit
213        self.width = width

Initializes the GridConfig.

Parameters
  • columns: (Required) List of column configurations.
  • data: (Optional) List of data objects.
  • adjust: (Optional) Auto adjust columns.
  • autoEmptyRow: (Optional) Adds an empty row after the last filled row.
  • autoHeight: (Optional) Makes long text split into multiple lines.
  • autoWidth: (Optional) Makes grid's columns fit the size of the grid.
  • bottomSplit: (Optional) Number of frozen rows from the bottom.
  • css: (Optional) Adds style classes to Grid.
  • dragCopy: (Optional) Defines whether a row is copied during drag-n-drop.
  • dragItem: (Optional) Enables reordering columns or rows by drag and drop.
  • dragMode: (Optional) Enables drag-n-drop in Grid.
  • editable: (Optional) Enables editing in Grid columns.
  • eventHandlers: (Optional) Adds event handlers to HTML elements in the grid.
  • exportStyles: (Optional) Defines the styles to be sent when exporting.
  • footerAutoHeight: (Optional) Allows adjusting the footer height.
  • footerRowHeight: (Optional) Sets the height of rows in the footer.
  • footerTooltip: (Optional) Controls the footer tooltips.
  • headerAutoHeight: (Optional) Allows adjusting the header height.
  • headerRowHeight: (Optional) Sets the height of rows in the header.
  • headerTooltip: (Optional) Controls the header tooltips.
  • height: (Optional) Sets the height of the grid.
  • htmlEnable: (Optional) Specifies the HTML content of Grid columns.
  • keyNavigation: (Optional) Enables keyboard navigation in Grid.
  • leftSplit: (Optional) Number of frozen columns from the left.
  • multiselection: (Optional) Enables multi-row/multi-cell selection.
  • resizable: (Optional) Defines whether columns can be resized.
  • rightSplit: (Optional) Number of frozen columns from the right.
  • rowCss: (Optional) Sets style for a row.
  • rowHeight: (Optional) Defines the height of a row.
  • selection: (Optional) Enables selection in the grid.
  • sortable: (Optional) Defines whether sorting is enabled.
  • spans: (Optional) Describes the configuration of spans.
  • tooltip: (Optional) Enables/disables all the tooltips of a column.
  • topSplit: (Optional) Number of frozen rows from the top.
  • width: (Optional) Sets the width of the grid.
columns
data
adjust
autoEmptyRow
autoHeight
autoWidth
bottomSplit
css
collapsed
type
dragCopy
dragItem
dragMode
editable
eventHandlers
exportStyles
footerAutoHeight
footerRowHeight
footerTooltip
headerAutoHeight
headerRowHeight
headerTooltip
height
htmlEnable
keyNavigation
leftSplit
multiselection
resizable
rightSplit
rowCss
rowHeight
selection
sortable
spans
tooltip
topSplit
width
def to_dict(self) -> Dict[str, Any]:
215    def to_dict(self) -> Dict[str, Any]:
216        """
217        Converts the GridConfig into a dictionary format.
218        """
219        config_dict = {
220            'columns': self.columns,
221            'data': self.data,
222            'adjust': self.adjust,
223            'autoEmptyRow': self.autoEmptyRow,
224            'autoHeight': self.autoHeight,
225            'autoWidth': self.autoWidth,
226            'bottomSplit': self.bottomSplit,
227            'css': self.css,
228            'type': self.type,
229            'dragCopy': self.dragCopy,
230            'dragItem': self.dragItem,
231            'dragMode': self.dragMode,
232            'editable': self.editable,
233            'eventHandlers': self.eventHandlers,
234            'exportStyles': self.exportStyles,
235            'footerAutoHeight': self.footerAutoHeight,
236            'footerRowHeight': self.footerRowHeight,
237            'footerTooltip': self.footerTooltip,
238            'headerAutoHeight': self.headerAutoHeight,
239            'headerRowHeight': self.headerRowHeight,
240            'headerTooltip': self.headerTooltip,
241            'height': self.height,
242            'htmlEnable': self.htmlEnable,
243            'keyNavigation': self.keyNavigation,
244            'leftSplit': self.leftSplit,
245            'multiselection': self.multiselection,
246            'resizable': self.resizable,
247            'rightSplit': self.rightSplit,
248            'rowCss': self.rowCss,
249            'rowHeight': self.rowHeight,
250            'selection': self.selection,
251            'sortable': self.sortable,
252            'spans': self.spans,
253            'tooltip': self.tooltip,
254            'topSplit': self.topSplit,
255            'width': self.width
256        }
257        # Remove None values
258        config_dict = {k: v for k, v in config_dict.items() if v is not None}
259
260        if self.columns:
261            config_dict['columns'] = [column.to_dict() for column in self.columns]
262
263        # Handle functions (e.g., rowCss)
264        if 'rowCss' in config_dict and callable(config_dict['rowCss']):
265            # Assuming rowCss is a JavaScript function
266            config_dict['rowCss'] = self.rowCss  # This may require further adaptation
267
268        return config_dict

Converts the GridConfig into a dictionary format.

class GridColumnConfig:
 5class GridColumnConfig:
 6    """
 7    Configuration class for Grid columns.
 8    """
 9    def __init__(self,
10                 id: str,
11                 header: List[Dict[str, Any]],
12                 type: str = None,
13                 width: int = None,
14                 align: str = None,
15                 adjust: bool = False,
16                 hidden: bool = False,
17                 sortable: bool = True,
18                 resizable: bool = True,
19                 tooltip: Union[bool, Dict[str, Any]] = True,
20                 css: str = None,
21                 htmlEnable: bool = True,
22                 editable: bool = False,
23                 filter: Dict[str, Any] = None,
24                 format: str = None,
25                 template: Callable[[Dict[str, Any]], str] = None,
26                 editorType: str = None,
27                 options: List[Dict[str, Any]] = None,
28                 gravity: int = None):
29        """
30        Initializes the GridColumnConfig.
31
32        :param id: (Required) The unique ID of the column.
33        :param header: (Required) The header configuration for the column.
34        :param type: (Optional) The data type of the column (e.g., 'string', 'number', 'date').
35        :param width: (Optional) The width of the column.
36        :param align: (Optional) The alignment of the column content ('left', 'center', 'right').
37        :param adjust: (Optional) Whether to auto-adjust the column width.
38        :param hidden: (Optional) Whether the column is hidden.
39        :param sortable: (Optional) Whether the column is sortable.
40        :param resizable: (Optional) Whether the column is resizable.
41        :param tooltip: (Optional) Tooltip configuration for the column.
42        :param css: (Optional) CSS classes for the column.
43        :param htmlEnable: (Optional) Whether to render HTML content in cells.
44        :param editable: (Optional) Whether the column cells are editable.
45        :param filter: (Optional) Filter configuration for the column.
46        :param format: (Optional) Format string for displaying data.
47        :param template: (Optional) Template function for custom cell rendering.
48        :param editorType: (Optional) Type of editor for editing cells (e.g., 'input', 'select').
49        :param options: (Optional) Options for select editors.
50        """
51        self.id = id
52        self.header = header
53        self.type = type
54        self.width = width
55        self.align = align
56        self.adjust = adjust
57        self.hidden = hidden
58        self.sortable = sortable
59        self.resizable = resizable
60        self.tooltip = tooltip
61        self.css = css
62        self.htmlEnable = htmlEnable
63        self.editable = editable
64        self.filter = filter
65        self.format = format
66        self.template = template
67        self.editorType = editorType
68        self.options = options
69        self.gravity = gravity
70
71    def to_dict(self) -> Dict[str, Any]:
72        config_dict = {
73            'id': self.id,
74            'header': self.header,
75            'type': self.type,
76            'width': self.width,
77            'align': self.align,
78            'adjust': self.adjust,
79            'hidden': self.hidden,
80            'sortable': self.sortable,
81            'resizable': self.resizable,
82            'tooltip': self.tooltip,
83            'css': self.css,
84            'htmlEnable': self.htmlEnable,
85            'editable': self.editable,
86            'filter': self.filter,
87            'format': self.format,
88            'template': self.template,
89            'editorType': self.editorType,
90            'options': self.options,
91            'gravity': self.gravity
92        }
93        return {k: v for k, v in config_dict.items() if v is not None}

Configuration class for Grid columns.

GridColumnConfig( id: str, header: List[Dict[str, Any]], type: str = None, width: int = None, align: str = None, adjust: bool = False, hidden: bool = False, sortable: bool = True, resizable: bool = True, tooltip: Union[bool, Dict[str, Any]] = True, css: str = None, htmlEnable: bool = True, editable: bool = False, filter: Dict[str, Any] = None, format: str = None, template: Callable[[Dict[str, Any]], str] = None, editorType: str = None, options: List[Dict[str, Any]] = None, gravity: int = None)
 9    def __init__(self,
10                 id: str,
11                 header: List[Dict[str, Any]],
12                 type: str = None,
13                 width: int = None,
14                 align: str = None,
15                 adjust: bool = False,
16                 hidden: bool = False,
17                 sortable: bool = True,
18                 resizable: bool = True,
19                 tooltip: Union[bool, Dict[str, Any]] = True,
20                 css: str = None,
21                 htmlEnable: bool = True,
22                 editable: bool = False,
23                 filter: Dict[str, Any] = None,
24                 format: str = None,
25                 template: Callable[[Dict[str, Any]], str] = None,
26                 editorType: str = None,
27                 options: List[Dict[str, Any]] = None,
28                 gravity: int = None):
29        """
30        Initializes the GridColumnConfig.
31
32        :param id: (Required) The unique ID of the column.
33        :param header: (Required) The header configuration for the column.
34        :param type: (Optional) The data type of the column (e.g., 'string', 'number', 'date').
35        :param width: (Optional) The width of the column.
36        :param align: (Optional) The alignment of the column content ('left', 'center', 'right').
37        :param adjust: (Optional) Whether to auto-adjust the column width.
38        :param hidden: (Optional) Whether the column is hidden.
39        :param sortable: (Optional) Whether the column is sortable.
40        :param resizable: (Optional) Whether the column is resizable.
41        :param tooltip: (Optional) Tooltip configuration for the column.
42        :param css: (Optional) CSS classes for the column.
43        :param htmlEnable: (Optional) Whether to render HTML content in cells.
44        :param editable: (Optional) Whether the column cells are editable.
45        :param filter: (Optional) Filter configuration for the column.
46        :param format: (Optional) Format string for displaying data.
47        :param template: (Optional) Template function for custom cell rendering.
48        :param editorType: (Optional) Type of editor for editing cells (e.g., 'input', 'select').
49        :param options: (Optional) Options for select editors.
50        """
51        self.id = id
52        self.header = header
53        self.type = type
54        self.width = width
55        self.align = align
56        self.adjust = adjust
57        self.hidden = hidden
58        self.sortable = sortable
59        self.resizable = resizable
60        self.tooltip = tooltip
61        self.css = css
62        self.htmlEnable = htmlEnable
63        self.editable = editable
64        self.filter = filter
65        self.format = format
66        self.template = template
67        self.editorType = editorType
68        self.options = options
69        self.gravity = gravity

Initializes the GridColumnConfig.

Parameters
  • id: (Required) The unique ID of the column.
  • header: (Required) The header configuration for the column.
  • type: (Optional) The data type of the column (e.g., 'string', 'number', 'date').
  • width: (Optional) The width of the column.
  • align: (Optional) The alignment of the column content ('left', 'center', 'right').
  • adjust: (Optional) Whether to auto-adjust the column width.
  • hidden: (Optional) Whether the column is hidden.
  • sortable: (Optional) Whether the column is sortable.
  • resizable: (Optional) Whether the column is resizable.
  • tooltip: (Optional) Tooltip configuration for the column.
  • css: (Optional) CSS classes for the column.
  • htmlEnable: (Optional) Whether to render HTML content in cells.
  • editable: (Optional) Whether the column cells are editable.
  • filter: (Optional) Filter configuration for the column.
  • format: (Optional) Format string for displaying data.
  • template: (Optional) Template function for custom cell rendering.
  • editorType: (Optional) Type of editor for editing cells (e.g., 'input', 'select').
  • options: (Optional) Options for select editors.
id
header
type
width
align
adjust
hidden
sortable
resizable
tooltip
css
htmlEnable
editable
filter
format
template
editorType
options
gravity
def to_dict(self) -> Dict[str, Any]:
71    def to_dict(self) -> Dict[str, Any]:
72        config_dict = {
73            'id': self.id,
74            'header': self.header,
75            'type': self.type,
76            'width': self.width,
77            'align': self.align,
78            'adjust': self.adjust,
79            'hidden': self.hidden,
80            'sortable': self.sortable,
81            'resizable': self.resizable,
82            'tooltip': self.tooltip,
83            'css': self.css,
84            'htmlEnable': self.htmlEnable,
85            'editable': self.editable,
86            'filter': self.filter,
87            'format': self.format,
88            'template': self.template,
89            'editorType': self.editorType,
90            'options': self.options,
91            'gravity': self.gravity
92        }
93        return {k: v for k, v in config_dict.items() if v is not None}