scroll
Description
Fires when scrollingUsage
"scroll": ({
column?: string | number,
row?: string | number
}) => boolean | void;
Parameters
The callback of the action takes an object with the following parameters:
column
- (optional) the id of a column the table is scrolled torow
- (optional) the id of a row the table is scrolled to
Returning false from the event handler will block scrolling withing the table.
Example
The example below shows how to enable scrolling to the first row and column on a button click.
import { Grid } from "wx-react-grid";
import { repeatData, repeatColumns } from "./common/data";
const data = repeatData(1000);
const columns = repeatColumns(100);
export default function App() {
const api = useRef(null);
function doScroll(row, column) {
api.current.exec("scroll", { row, column });
}
return (
<>
<button onClick={() => doScroll(data[4].id, columns[4].id)}>
Scroll to First Row / Column
</button>
<Grid api={api} data={data} columns={columns} />
</>
);
}
Related articles: