react-table-library icon indicating copy to clipboard operation
react-table-library copied to clipboard

CompactTable and row props

Open gius opened this issue 3 years ago • 2 comments

Is it possible to set row props based on the row data in CompactTable? For example, I would like a row background based on the data status (red/green).

If not, could we introduce a new property getRowProps: (item: TableNode, index: number) => CompactRowProps to CompactTableProps? The logic should be that if this property is provided, it would be used to create rowProps that are passed to CompactRow.

gius avatar Dec 09 '22 22:12 gius

I would check out the Composed Table and style the rows as you wish over there.

rwieruch avatar Dec 10 '22 19:12 rwieruch

Composed table requires a lot of other work (generating columns, cells, etc.) CompactTable is really a great fit for data-heavy apps, its configuration is very straightforward! Only the row-specific props are missing. One would have to copy-paste (and then keep up-to-date with new RCT versions) the whole CompactTable, VirtualizedTable, and NormalTable to add a simple logic like:

(in NormalTable.tsx)
...
      <Body>
        {tableList.map((item: TableNode, index: number) => (
          <CompactRow
            key={item.id}
            index={index}
            item={item}
            columns={columns}
            rowProps={getRowProps ? getRowProps(item, index) : rowProps} // only this has been changed
            rowOptions={rowOptions}
            {...tableProps}
          />
        ))}
      </Body>

gius avatar Dec 12 '22 16:12 gius