Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal scroll in React Table

I have a problem to get pretty basic functionality, ie. I'd like to set horizontal scroll on React table when the page is less wider then the table size. There is nothing unusual in my code but I'll leave it here anyway:

<ReactTable
  data={bookingPerson}
  columns={columns}
  className="-striped -highlight"
  defaultPageSize={7}
  loading={loading}
/>
like image 343
Murakami Avatar asked Aug 29 '18 12:08

Murakami


People also ask

How do I add a horizontal scroll in react table?

Just simply add style with a height of 400px, that will force it to be scroll able.

How do I add a scroll to react table?

import React, { useMemo } from "react"; import useData from "../../hooks/useData"; import Table from "./Table"; const TableSection = React. memo(({ query }) => { const { data, runtime, error } = useData(query); const column = data. length > 0 && Object. keys(data[0]).

How do you make a material table scrollable in react?

you can use maxBodyHeight property, which will create vertical scrollbar if data exceeding the given height. Save this answer.

How do I freeze a column in react table?

Frozen Rows and Columns (React) You can freeze rows and columns by setting the grid's frozenRows and frozenColumns properties. Frozen cells do not scroll but are selectable and editable like regular cells.


1 Answers

Just simply add style with a height of 400px, that will force it to be scroll able.

<ReactTable
      data={bookingPerson}
      columns={columns}
      className="-striped -highlight"
      defaultPageSize={7}
      loading={loading}
      style={{
        height: "400px"
      }}
 />
like image 130
Tamal Avatar answered Oct 18 '22 09:10

Tamal