Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
import { useEffect, useState } from "react";
import axios from "axios";
import { AgGridReact } from 'ag-grid-react';
import React from 'react';
import 'ag-grid-community/dist/styles/ag-grid.css';
import 'ag-grid-community/dist/styles/ag-theme-alpine.css';

function Read(props) {
  const \[record, setRecord\] = useState('');

  useEffect(() => {
    axios.get('https://jsonplaceholder.typicode.com/comments')
    .then((response) =>{
      console.log(response.data);
      setRecord(response.data);
    })
  }, \[\])

  function update(data){
    console.log("hello");
  }

const col= \[
    { headerName: "Name", field: "name"},
    { headerName: "Email", field: "email"},
    { headerName: "Body", field: "body"},
    {headerName: "", headerClass: 'new-class',
        cellRendererFramework:(params)=>
        <div>
                  <button onClick={() => update(params.data)}>Edit</button>
        </div>}
  \]

  return (
    <>
        <div className="ag-theme-alpine" style={{height:'400px',
        width: '700px'}}>
        <AgGridReact
            columnDefs={col}
            rowData={record}
            pagination={true}
            >
        </AgGridReact>
      </div>
    </>
  );
}

export default Read;


What I have tried:

i am trying to get numbers in the pagination so if any one wants to go on a page they click on that page and they will get to that page but i can't find anything on google.
Posted
Comments
Richard Deeming 14-Dec-21 4:07am    
Literally the first result from Google:
https://www.ag-grid.com/react-data-grid/row-pagination/[^]
Happy kaul 14-Dec-21 5:23am    
are you kidding me i saw that already and i used it i think you didn't get my question. i want page numbers like 1, 2, 3, 4 in bottom
Richard Deeming 14-Dec-21 5:26am    
If you can't be bothered to ask a proper question, then don't expect anyone to put any effort into providing an answer. Nobody here is going to write your code for you - you need to explain precisely what you have tried and where you are stuck. Don't just dump your entire code and expect us to wade through it work out what your question is!
Happy kaul 14-Dec-21 5:41am    
i am not here to fight please be mature it will be helpful if you can help rather than poke someone.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900