Skip to content

DataRow2

DataRow2 #

Bases: DataRow

Extends flet.DataRow, adding row-level tap events.

There are also on_secondary_tap and on_secondary_tap_down, which are not available in DataCells and can be useful in desktop settings to handle right-click actions.

badge #

badge: BadgeValue | None = None

A badge to show on top of this control.

cells #

cells: list[DataCell] = field(default_factory=list)

The data for this row - a list of DataCell controls.

Note

There must be exactly as many cells as there are columns in the table.

col #

col: ResponsiveNumber = 12

If a parent of this control is a ResponsiveRow, this property is used to determine how many virtual columns of a screen this control will span.

Can be a number or a dictionary configured to have a different value for specific breakpoints, for example col={"sm": 6}.

This control spans the 12 virtual columns by default.

/// details | Dimensions type: info | Breakpoint | Dimension | |---|---| | xs | <576px | | sm | ≥576px | | md | ≥768px | | lg | ≥992px | | xl | ≥1200px | | xxl | ≥1400px | ///

color #

color: ControlStateValue[ColorValue] | None = None

The color for the row.

By default, the color is transparent unless selected. Selected rows has a grey translucent color.

The effective color can depend on the ControlState state, if the row is selected, pressed, hovered, focused, disabled or enabled. The color is painted as an overlay to the row. To make sure that the row's InkWell is visible (when pressed, hovered and focused), it is recommended to use a translucent color.

data #

data: Any = skip_field()

Arbitrary data of any type.

decoration #

decoration: BoxDecoration | None = None

Decoration to be applied to this row.

Note

If provided, DataTable2.divider_thickness has no effect.

disabled #

disabled: bool = False

Every control has disabled property which is False by default - control and all its children are enabled.

Note

The value of this property will be propagated down to all children controls recursively.

/// details | Example type: example For example, if you have a form with multiple entry controls you can disable them all together by disabling container:

ft.Column(
    disabled = True,
    controls=[
        ft.TextField(),
        ft.TextField()
    ]
)
///

expand #

expand: bool | int | None = None

Specifies whether/how this control should expand to fill available space in its parent layout.

More information here.

Note

Has effect only if the direct parent of this control is one of the following controls, or their subclasses: Column, Row, View, Page.

expand_loose #

expand_loose: bool = False

Allows the control to expand along the main axis if space is available, but does not require it to fill all available space.

More information here.

Note

If expand_loose is True, it will have effect only if:

  • expand is not None and
  • the direct parent of this control is one of the following controls, or their subclasses: Column, Row, View, Page.

key #

key: KeyValue | None = None

on_double_tap #

on_double_tap: ControlEventHandler[DataRow2] | None = None

Fires when the row is double-tapped.

Note

Won't be called if tapped cell has any tap event handlers (on_tap, on_double_tap, on_long_press, on_tap_cancel, on_tap_down) set.

on_long_press #

on_long_press: ControlEventHandler[DataRow] | None = None

Called if the row is long-pressed.

If a DataCell in the row has its DataCell.on_tap, DataCell.on_double_tap, DataCell.on_long_press, DataCell.on_tap_cancel or DataCell.on_tap_down callback defined, that callback behavior overrides the gesture behavior of the row for that particular cell.

on_secondary_tap #

on_secondary_tap: ControlEventHandler[DataRow2] | None = (
    None
)

Fires when the row is right-clicked (secondary tap).

Note

Won't be called if tapped cell has any tap event handlers (on_tap, on_double_tap, on_long_press, on_tap_cancel, on_tap_down) set.

on_secondary_tap_down #

on_secondary_tap_down: (
    ControlEventHandler[DataRow2] | None
) = None

Fires when the row is right-clicked (secondary tap down).

Note

Won't be called if tapped cell has any tap event handlers (on_tap, on_double_tap, on_long_press, on_tap_cancel, on_tap_down) set.

on_select_change #

on_select_change: ControlEventHandler[DataRow] | None = None

Called when the user selects or unselects a selectable row.

If this is not null, then this row is selectable. The current selection state of this row is given by selected.

If any row is selectable, then the table's heading row will have a checkbox that can be checked to select all selectable rows (and which is checked if all the rows are selected), and each subsequent row will have a checkbox to toggle just that row.

A row whose on_select_change callback is null is ignored for the purposes of determining the state of the "all" checkbox, and its checkbox is disabled.

If a DataCell in the row has its DataCell.on_tap callback defined, that callback behavior overrides the gesture behavior of the row for that particular cell.

on_tap #

on_tap: EventHandler[TapEvent[DataRow2]] | None = None

Fires when the row is tapped.

Note

Won't be called if tapped cell has any tap event handlers (on_tap, on_double_tap, on_long_press, on_tap_cancel, on_tap_down) set.

opacity #

opacity: Number = 1.0

Defines the transparency of the control.

Value ranges from 0.0 (completely transparent) to 1.0 (completely opaque without any transparency).

page #

page: Page | BasePage | None

The page to which this control belongs to.

parent #

parent: BaseControl | None

The direct ancestor(parent) of this control.

It defaults to None and will only have a value when this control is mounted (added to the page tree).

The Page control (which is the root of the tree) is an exception - it always has parent=None.

rtl #

rtl: bool = False

Whether the text direction of the control should be right-to-left (RTL).

selected #

selected: bool = False

Whether the row is selected.

If on_select_change is non-null for any row in the table, then a checkbox is shown at the start of each row. If the row is selected (True), the checkbox will be checked and the row will be highlighted.

Otherwise, the checkbox, if present, will not be checked.

specific_row_height #

specific_row_height: Number | None = None

Specific row height.

Falls back to DataTable2.data_row_height if not set.

tooltip #

tooltip: TooltipValue | None = None

The tooltip ot show when this control is hovered over.

visible #

visible: bool = True

Every control has visible property which is True by default - control is rendered on the page. Setting visible to False completely prevents control (and all its children if any) from rendering on a page canvas. Hidden controls cannot be focused or selected with a keyboard or mouse and they do not emit any events.

before_event #

before_event(e: ControlEvent)

before_update #

before_update()

build #

build()

Called once during control initialization to define its child controls. self.page is available in this method.

clean #

clean() -> None

did_mount #

did_mount()

init #

init()

is_isolated #

is_isolated()

update #

update() -> None

will_unmount #

will_unmount()