@@ -137,6 +137,11 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
137
137
defaultSortColumn,
138
138
} = useColumns ( columns , onColumnOrderChange , defaultSortFieldId , defaultSortAsc ) ;
139
139
140
+ const freezedColumns = React . useMemo ( ( ) => {
141
+ const index = tableColumns . findIndex ( column => column . freeze ) ;
142
+ return tableColumns . slice ( 0 , index + 1 ) ;
143
+ } , [ tableColumns ] ) ;
144
+
140
145
const [
141
146
{
142
147
rowsPerPage,
@@ -448,16 +453,138 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
448
453
{ subHeaderComponent }
449
454
</ Subheader >
450
455
) }
451
-
452
- < ResponsiveWrapper
453
- responsive = { responsive }
454
- fixedHeader = { fixedHeader }
455
- fixedHeaderScrollHeight = { fixedHeaderScrollHeight }
456
- { ...wrapperProps }
457
- >
458
- < Wrapper >
459
- { progressPending && ! persistTableHead && < ProgressWrapper > { progressComponent } </ ProgressWrapper > }
460
-
456
+ < div style = { { position : 'relative' } } >
457
+ < ResponsiveWrapper
458
+ responsive = { responsive }
459
+ fixedHeader = { fixedHeader }
460
+ fixedHeaderScrollHeight = { fixedHeaderScrollHeight }
461
+ { ...wrapperProps }
462
+ >
463
+ < Wrapper >
464
+ { progressPending && ! persistTableHead && < ProgressWrapper > { progressComponent } </ ProgressWrapper > }
465
+
466
+ < Table disabled = { disabled } className = "rdt_Table" role = "table" >
467
+ { showTableHead ( ) && (
468
+ < Head className = "rdt_TableHead" role = "rowgroup" fixedHeader = { fixedHeader } >
469
+ < HeadRow className = "rdt_TableHeadRow" role = "row" dense = { dense } >
470
+ { keepExpandableFirst ? (
471
+ < >
472
+ { expandableHeaderCol }
473
+ { selectableHeaderCol }
474
+ </ >
475
+ ) : (
476
+ < >
477
+ { selectableHeaderCol }
478
+ { expandableHeaderCol }
479
+ </ >
480
+ ) }
481
+
482
+ { tableColumns . map ( column => (
483
+ < Column
484
+ key = { column . id }
485
+ column = { column }
486
+ selectedColumn = { selectedColumn }
487
+ disabled = { progressPending || sortedData . length === 0 }
488
+ pagination = { pagination }
489
+ paginationServer = { paginationServer }
490
+ persistSelectedOnSort = { persistSelectedOnSort }
491
+ selectableRowsVisibleOnly = { selectableRowsVisibleOnly }
492
+ sortDirection = { sortDirection }
493
+ sortIcon = { sortIcon }
494
+ sortServer = { sortServer }
495
+ onSort = { handleSort }
496
+ onDragStart = { handleDragStart }
497
+ onDragOver = { handleDragOver }
498
+ onDragEnd = { handleDragEnd }
499
+ onDragEnter = { handleDragEnter }
500
+ onDragLeave = { handleDragLeave }
501
+ draggingColumnId = { draggingColumnId }
502
+ currentSortColumnId = { currentSortColumnId }
503
+ currentSortDirection = { currentSortDirection }
504
+ />
505
+ ) ) }
506
+ </ HeadRow >
507
+ </ Head >
508
+ ) }
509
+
510
+ { ! sortedData . length && ! progressPending && < NoData > { noDataComponent } </ NoData > }
511
+
512
+ { progressPending && persistTableHead && < ProgressWrapper > { progressComponent } </ ProgressWrapper > }
513
+
514
+ { ! progressPending && sortedData . length > 0 && (
515
+ < Body className = "rdt_TableBody" role = "rowgroup" >
516
+ { tableRows . map ( ( row , i ) => {
517
+ const key = prop ( row as TableRow , keyField ) as string | number ;
518
+ const id = isEmpty ( key ) ? i : key ;
519
+ const selected = isRowSelected ( row , selectedRows , keyField ) ;
520
+ const expanded = isRowExpanded ( row , expandedRows , keyField ) ;
521
+ const expanderExpander = ! ! ( expandableRows && expandableRowExpanded && expandableRowExpanded ( row ) ) ;
522
+ const expanderDisabled = ! ! ( expandableRows && expandableRowDisabled && expandableRowDisabled ( row ) ) ;
523
+
524
+ return (
525
+ < Row
526
+ id = { id }
527
+ key = { id }
528
+ keyField = { keyField }
529
+ data-row-id = { id }
530
+ columns = { tableColumns }
531
+ row = { row }
532
+ rowCount = { sortedData . length }
533
+ rowIndex = { i }
534
+ selectableRows = { selectableRows }
535
+ expandableRows = { expandableRows }
536
+ expandableIcon = { expandableIcon }
537
+ highlightOnHover = { highlightOnHover }
538
+ pointerOnHover = { pointerOnHover }
539
+ dense = { dense }
540
+ expandOnRowClicked = { expandOnRowClicked }
541
+ expandOnRowDoubleClicked = { expandOnRowDoubleClicked }
542
+ expandableRowsComponent = { expandableRowsComponent }
543
+ expandableRowsComponentProps = { expandableRowsComponentProps }
544
+ expandableRowsHideExpander = { expandableRowsHideExpander }
545
+ defaultExpanderDisabled = { expanderDisabled }
546
+ defaultExpanded = { expanderExpander }
547
+ expandableInheritConditionalStyles = { expandableInheritConditionalStyles }
548
+ conditionalRowStyles = { conditionalRowStyles }
549
+ selected = { selected }
550
+ expanded = { expanded }
551
+ selectableRowsHighlight = { selectableRowsHighlight }
552
+ selectableRowsComponent = { selectableRowsComponent }
553
+ selectableRowsComponentProps = { selectableRowsComponentProps }
554
+ selectableRowDisabled = { selectableRowDisabled }
555
+ expandableRowDisabled = { expandableRowDisabled }
556
+ selectableRowsSingle = { selectableRowsSingle }
557
+ expandableRowsSingle = { expandableRowsSingle }
558
+ striped = { striped }
559
+ keepExpandableFirst = { keepExpandableFirst }
560
+ onRowExpandToggled = { onRowExpandToggled }
561
+ onRowClicked = { handleRowClicked }
562
+ onRowDoubleClicked = { handleRowDoubleClicked }
563
+ onSelectedRow = { handleSelectedRow }
564
+ onExpandedRow = { handleExpandedRow }
565
+ draggingColumnId = { draggingColumnId }
566
+ onDragStart = { handleDragStart }
567
+ onDragOver = { handleDragOver }
568
+ onDragEnd = { handleDragEnd }
569
+ onDragEnter = { handleDragEnter }
570
+ onDragLeave = { handleDragLeave }
571
+ />
572
+ ) ;
573
+ } ) }
574
+ </ Body >
575
+ ) }
576
+ </ Table >
577
+ { footer && < div > { footer } </ div > }
578
+ </ Wrapper >
579
+ </ ResponsiveWrapper >
580
+
581
+ < div
582
+ style = { {
583
+ position : 'absolute' ,
584
+ top : 0 ,
585
+ left : 0 ,
586
+ } }
587
+ >
461
588
< Table disabled = { disabled } className = "rdt_Table" role = "table" >
462
589
{ showTableHead ( ) && (
463
590
< Head className = "rdt_TableHead" role = "rowgroup" fixedHeader = { fixedHeader } >
@@ -474,7 +601,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
474
601
</ >
475
602
) }
476
603
477
- { tableColumns . map ( column => (
604
+ { freezedColumns . slice ( 0 , 3 ) . map ( column => (
478
605
< Column
479
606
key = { column . id }
480
607
column = { column }
@@ -502,10 +629,6 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
502
629
</ Head >
503
630
) }
504
631
505
- { ! sortedData . length && ! progressPending && < NoData > { noDataComponent } </ NoData > }
506
-
507
- { progressPending && persistTableHead && < ProgressWrapper > { progressComponent } </ ProgressWrapper > }
508
-
509
632
{ ! progressPending && sortedData . length > 0 && (
510
633
< Body className = "rdt_TableBody" role = "rowgroup" >
511
634
{ tableRows . map ( ( row , i ) => {
@@ -522,7 +645,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
522
645
key = { id }
523
646
keyField = { keyField }
524
647
data-row-id = { id }
525
- columns = { tableColumns }
648
+ columns = { freezedColumns }
526
649
row = { row }
527
650
rowCount = { sortedData . length }
528
651
rowIndex = { i }
@@ -570,8 +693,8 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
570
693
) }
571
694
</ Table >
572
695
{ footer && < div > { footer } </ div > }
573
- </ Wrapper >
574
- </ ResponsiveWrapper >
696
+ </ div >
697
+ </ div >
575
698
576
699
{ enabledPagination && (
577
700
< div >
0 commit comments