Add border to the expanded row as well as to all of the sub rows

36 views Asked by At

I want to add border to the expanded row as well as to all of the sub rows which are shown after expanding as shown below images. First image shows the current behavior of the UI and second image is figma screenshot which shows the expected behavior of the UI.

My current code -

<MaterialReactTable
        columns={columns}
        data={data}
        state={{ isLoading }}
        enableColumnActions={false}
        enableColumnFilters={false}
        enableFullScreenToggle={false}
        enableDensityToggle={false}
        enableHiding={false}
        enableGlobalFilter={false}
        enableColumnDragging={false}
        enableGrouping
        enableExpanding
        positionExpandColumn='last'
        initialState={{
          density: 'comfortable',
          showGlobalFilter: true,
          grouping: ['drugName']
        }}
        muiExpandButtonProps={({ row }) => ({
          sx: {
            display:
              row.subRows !== undefined && row.subRows?.length > 0
                ? 'flex'
                : 'none'
          }
        })}
        muiExpandAllButtonProps={{ sx: { display: 'none' } }}
        muiToolbarAlertBannerProps={{ sx: { display: 'none' } }}
        enablePagination={data?.length !== 0}
        enableRowActions={hasWritePermission(
          userPermissions,
          allEntityList.accumulator
        )}
        positionActionsColumn='last'
        displayColumnDefOptions={{
          'mrt-row-actions': {
            header: '',
            size: 20
          }
        }}
        renderRowActionMenuItems={({ row }) => [
          <MenuItem key='edit'>Edit Units at hand</MenuItem>
        ]}
        localization={{ noRecordsToDisplay: 'No Data Available' }}
        muiTableBodyRowProps={({ row }) => ({
          sx: {
            border: row.getIsExpanded() ? '2px solid #448df2' : 'unset',
            backgroundColor: row.getIsExpanded() ? '#f0f1f3' : '',
            '&:hover > td': {
              backgroundColor: '#b6d3fa'
            }
          }
        })}
        muiTableContainerProps={{
          sx: {
            minHeight: data?.length === 0 ? 'none' : '65vh'
          }
        }}
        muiTableBodyCellProps={({ row, column }) => ({
          title: getTableCellTitle(row, column),
          sx: {
            maxWidth: '4rem'
          }
        })}
        muiTableProps={{
          sx: {
            borderCollapse: 'collapse'
          }
        }}
      />

Current Behavior - enter image description here

Expected Behavior - enter image description here

0

There are 0 answers