question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a display rows per page dropdown or textbox with pagination

See original GitHub issue

Is your feature request related to a problem? Please describe. It would be nice to add a dropdown to select how many rows user wants to show per page like this image

Describe the solution you’d like I think the prop recordPerPage should show the dropdown so that both dropdown and page info can be sync

Describe alternatives you’ve considered An alternative can be to add a withLimitDropdown prop to table which if it is true it should show the limit dropdown and get the value from recordsPerPage state

<DataTable
  recordsPerPage="10"
  withLimitDropdown
/>

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
icflorescucommented, Oct 31, 2022

This should work in v1.7.13 🎉

1reaction
Muhammad-Arsalan31commented, Oct 24, 2022

Hi, I have worked on the feature and named the props as you mentioned above. but data types are different for onRecordsPerPageChange and recordsPerPageOptions they are

onRecordsPerPageChange: ((value: string | null) => void) | undefined; recordsPerPageOptions: string[];

the reason for this is that the select component takes values as a string array

   <Select
      onChange={onPerPageOptionChange}
      value={`${recordsPerPage}`}
      size={paginationSize}
      data={recordsPerPageOptions as (string | SelectItem)[]}
      sx={{ width: '80px' }}
   />

also, I am getting a typescript error if I don’t pass these props to DataTable component. I have made them optional but I don’t know why this error is occurring can you help me with this

Type '{ withBorder: true; records: { id: string; firstName: string; lastName: string; email: string; birthDate: string;
 departmentId: string; }[]; columns: ({ accessor: string; width: number; } | { accessor: string; width: string; } | 
{ ...; })[]; ... 4 more ...; paginationColor: "ffaa11"; }' is not assignable to type 'IntrinsicAttributes & 
DataTableProps<{ id: string; firstName: string; lastName: string; email: string; birthDate: string; 
departmentId: string; }>'.
Translation: I was expecting a type matching A, but instead you passed B.

theses are some issues I am facing if I can fix these issues then I can submit the PR

also, the Ui is like this

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

add more options in records per page dropdown using ...
Everything is working fine, but now I want to be able to select more than the default options of records per page, by...
Read more >
Row Pagination - JavaScript Data Grid
If you set paginationAutoPageSize=true the grid will automatically show as many rows in each page as it can fit. This is demonstrated below....
Read more >
Pagination: Let the user choose how many items are shown ...
I'm rewriting an application which had pagination of datagrids and a user configurable "item per page" value. Now the new application only have...
Read more >
Add sorting, filtering, and paging - ASP.NET MVC with EF Core
In this tutorial you'll add sorting, filtering, and paging functionality to the Students Index page. You'll also create a page that does ...
Read more >
DataTables lengthChange Option - GeeksforGeeks
The lengthChange option is used to specify whether the dropdown to change the number of rows per page is displayed or not.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found