Table constructor
Table({
- List<
TableColumn> columns = const [], - List<
TableRowData> rows = const [], - Object? emptyState,
- bool loading = false,
- Object? loadingState,
- String? className,
- Map<
String, Object?> props = const {}, - Map<
String, Object?> style = const {}, - DartStyle? dartStyle,
- String? tableClassName,
- Map<
String, Object?> tableProps = const {}, - Map<
String, Object?> tableStyle = const {}, - DartStyle? tableDartStyle,
- String? headerClassName,
- Map<
String, Object?> headerStyle = const {}, - DartStyle? headerDartStyle,
- String? rowClassName,
- String? selectedRowClassName,
- Map<
String, Object?> rowStyle = const {}, - Map<
String, Object?> selectedRowStyle = const {}, - DartStyle? rowDartStyle,
- DartStyle? selectedRowDartStyle,
- String? cellClassName,
- Map<
String, Object?> cellStyle = const {}, - DartStyle? cellDartStyle,
- void onRowClick(
- Object event,
- TableRowData row
Creates a table from columns and rows.
Implementation
Table({
List<TableColumn> columns = const [],
List<TableRowData> rows = const [],
Object? emptyState,
bool loading = false,
Object? loadingState,
String? className,
Map<String, Object?> props = const {},
Map<String, Object?> style = const {},
DartStyle? dartStyle,
String? tableClassName,
Map<String, Object?> tableProps = const {},
Map<String, Object?> tableStyle = const {},
DartStyle? tableDartStyle,
String? headerClassName,
Map<String, Object?> headerStyle = const {},
DartStyle? headerDartStyle,
String? rowClassName,
String? selectedRowClassName,
Map<String, Object?> rowStyle = const {},
Map<String, Object?> selectedRowStyle = const {},
DartStyle? rowDartStyle,
DartStyle? selectedRowDartStyle,
String? cellClassName,
Map<String, Object?> cellStyle = const {},
DartStyle? cellDartStyle,
void Function(Object event, TableRowData row)? onRowClick,
}) : super(
'div',
props: mergeComponentProps(
props,
className: className,
defaultStyle: const {
'overflow-x': 'auto',
'border': '1px solid #e4e7ec',
'border-radius': '8px',
'background': '#ffffff',
},
dartStyle: dartStyle,
style: style,
),
children: [
if (loading)
toFlintNode(loadingState ?? 'Loading...')
else if (rows.isEmpty)
toFlintNode(emptyState ?? 'No records found.')
else
FlintElement(
'table',
props: mergeComponentProps(
tableProps,
className: tableClassName,
defaultStyle: const {
'width': '100%',
'border-collapse': 'collapse',
},
dartStyle: tableDartStyle,
style: tableStyle,
),
children: [
_thead(
columns,
headerClassName: headerClassName,
headerStyle: headerStyle,
headerDartStyle: headerDartStyle,
),
_tbody(
columns,
rows,
onRowClick,
rowClassName: rowClassName,
selectedRowClassName: selectedRowClassName,
rowStyle: rowStyle,
selectedRowStyle: selectedRowStyle,
rowDartStyle: rowDartStyle,
selectedRowDartStyle: selectedRowDartStyle,
cellClassName: cellClassName,
cellStyle: cellStyle,
cellDartStyle: cellDartStyle,
),
],
),
],
);