2

How can I make the table header fixed on top on vertical scroll in antd? I have used css like position: fixed, top: 0. But these are not working in my case

<DraggableANTGrid
                    dragProps={this.dragProps}
                    isDraggable={false}
                    tableProps={{
                        rowKey: "IndianExpImpId",
                        columns: finalColumns,
                        components: { header: { cell: ResizeableColumn } },
                        dataSource: rows,
                        onChange: this.onFilterChange,
                        size: "small",
                        scroll: { x: totalWidth + 96, y: 700 },
                        expandedRowRender: this.getExpandRow,
                        pagination: false,
                        rowSelection: {
                            selectedRowKeys: importExportIds,
                            onChange: this.rowSelection,
                            fixed: finalColumns.length > 2
                        }
                    }} />
Chandan Kumar
  • 21
  • 1
  • 2

2 Answers2

2

try this prop, i've worked it out..!!

scroll={{x:950,y:"calc(100vh - 220px)" }}
1

For antd table props, scroll={y: ...} allows you to fix your table header. However, the scroll property is not compatible with expandedRowRender property. You'll have to choose one of them. A possible solution is to use only scroll property, remove expandedRowRender and display it's content in a Modal whenever the row is clicked.

JayCodist
  • 2,424
  • 2
  • 12
  • 28