0

I am facing problem to display last page when user clicks on add new row..If we can display the last page,user can view the newly added row directly..i am using prime react with react js

  • Hi Meera, welcome. You need to add an example of the code you're using before we can begin to help – WurmD May 06 '21 at 17:57

1 Answers1

0

What you can do is use useRef hook in order to reference DataTable component and then manually change its state on adding the row

const dataTable = useRef(null);

then reference it at your component

<DataTable value={results} paginator rows={5} ref={dataTable}>

and finally implement your custom method by adding at the end this

  const goToLastPage = () => {
    dataTable.current.setState({
      first:
        Math.ceil(results.length / dataTable.current.state.rows) *
        dataTable.current.state.rows - dataTable.current.state.rows
    });
  };

Check this sandbox

Apostolos
  • 10,033
  • 5
  • 24
  • 39