Reflex Logo
Docs Logo
Library

/

Tables And Data Grids

/

Data Editor

A datagrid editor based on Glide Data Grid

This component is introduced as an alternative to the datatable to support editing the displayed data.

The columns definition should be a list of dict, each dict describing the associated columns. Property of a column dict:

  • title: The text to display in the header of the column.
  • id: An id for the column, if not defined, will default to a lower case of title
  • width: The width of the column.
  • type: The type of the columns, default to "str".

The data props of rx.data_editor accept a list of list, where each list represent a row of data to display in the table.

Here is a basic example of using the data_editor representing data with no interaction and no styling. Below we define the columns and the data which are taken in by the rx.data_editor component. When we define the columns we must define a title and a type for each column we create. The columns in the data must then match the defined type or errors will be thrown.

Here we define a State, as shown below, that allows us to print the location of the cell as a heading when we click on it, using the on_cell_clicked event trigger. Check out all the other event triggers that you can use with datatable at the bottom of this page. We also define a group with a label Data. This groups all the columns with this group label under a larger group Data as seen in the table below.

Cell clicked:

Now let's style our datatable to make it look more aesthetic and easier to use. We must first import DataEditorTheme and then we can start setting our style props as seen below in dark_theme.

We then set these themes using theme=DataEditorTheme(**dark_theme). On top of the styling we can also set some props to make some other aesthetic changes to our datatable. We have set the row_height to equal 50 so that the content is easier to read. We have also made the smooth_scroll_x and smooth_scroll_y equal True so that we can smoothly scroll along the columns and rows. Finally, we added column_select=single, where column select can take any of the following values none, single or multiple.

API Reference

rx.data_editor

The DataEditor Component.

PropType | ValuesDefault
rows
int
-
columns
Sequence
-
data
Sequence
-
get_cell_content
str
-
get_cells_for_selection
bool
-
draw_focus_ring
bool
-
fixed_shadow_x
bool
-
fixed_shadow_y
bool
-
fill_handle
bool
-
freeze_columns
int
-
group_header_height
int
-
header_height
int
-
max_column_auto_width
int
-
max_column_width
int
-
min_column_width
int
-
row_height
int
-
row_markers
"none" | "number" | ...
-
row_marker_start_index
int
-
row_marker_width
int
-
smooth_scroll_x
bool
-
smooth_scroll_y
bool
-
vertical_border
bool
-
column_select
"none" | "single" | ...
-
range_select
"none" | "cell" | ...
-
row_select
"none" | "single" | ...
-
prevent_diagonal_scrolling
bool
-
overscroll_x
int
-
overscroll_y
int
-
scroll_offset_x
int
-
scroll_offset_y
int
-
range_selection_blending
"exclusive" | "mixed"
-
column_selection_blending
"exclusive" | "mixed"
-
row_selection_blending
"exclusive" | "mixed"
-
row_selection_mode
"auto" | "multi"
-
span_range_behavior
"default" | "allowPartial"
-
theme
Union[DataEditorTheme, dict]
-
grid_selection
GridSelection
-
show_search
bool
-

Event Triggers

See the full list of default event triggers
TriggerDescription
on_cell_activatedFired when a cell is activated.
on_cell_clickedFired when a cell is clicked.
on_cell_context_menuFired when a cell is right-clicked.
on_cell_editedFired when a cell is edited.
on_group_header_clickedFired when a group header is clicked.
on_group_header_context_menuFired when a group header is right-clicked.
on_group_header_renamedFired when a group header is renamed.
on_header_clickedFired when a header is clicked.
on_header_context_menuFired when a header is right-clicked.
on_header_menu_clickFired when a header menu item is clicked.
on_item_hoveredFired when an item is hovered.
on_deleteFired when a selection is deleted.
on_finished_editingFired when editing is finished.
on_row_appendedFired when a row is appended.
on_grid_selection_changeFired when the grid selection changes. Will pass the current selection, the selected columns and the selected rows.
on_selection_clearedFired when the selection is cleared.
on_column_resizeFired when a column is resized.
on_search_closeFired when the search close button is clicked.

Built with Reflex