table icon indicating copy to clipboard operation
table copied to clipboard

table.setPageCount is not updating pageCount

Open lakshmanang opened this issue 1 year ago • 6 comments

Describe the bug

table.setPageCount not updating pageCount.

const table = useReactTable({
   data: dataQuery.data?.rows ?? defaultData,
   columns,
   pageCount:  10,
   state: {
     pagination,
   },
   onPaginationChange: setPagination,
   getCoreRowModel: getCoreRowModel(),
   manualPagination: true,
   // getPaginationRowModel: getPaginationRowModel(), // If only doing manual pagination, you don't need this
   debugTable: true,
 })
React.useEffect(() => {
   console.log("asdfasdf");
   table.setPageCount(20)
 },[])

Actual result: console.log(table.getPageCount()); // 10

Please suggest a way to change pageCount.

Your minimal, reproducible example

Not available

Steps to reproduce

1.Set pageCount=10 in useReactTableOptions 2. change pageCount somewhere outside by table.setPageCount(20)

Expected behavior

Expected result:

console.log(table.getPageCount()); // 20

How often does this bug happen?

None

Screenshots or Videos

image image

Platform

windows 11, Chrome

react-table version

^8.8.4

TypeScript version

No response

Additional context

No response

Terms & Code of Conduct

  • [x] I agree to follow this project's Code of Conduct
  • [X] I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

lakshmanang avatar Jun 16 '23 07:06 lakshmanang

Hi Jangmin,

  1. Here we are developing Compound table component. Creating table instance is in TableContext and passing down. PageCount will be calculate(using totalDataCount) inside of PaginationFooter component. So I am in the need of changing PageCount after the tableInstance creation.

@.***

2.Another think is, PageCount can be dynamic here. Whenever user request to see the total count we will fetch and so. At the time also I want to use table.setPageCount.

@.***

Thanks Lakshmanan

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

From: Jangmin @.> Sent: 16 June 2023 11:33 PM To: @.> Cc: Lakshmanan @.>; @.> Subject: Re: [TanStack/table] table.setPageCount is not updating pageCount (Issue #4918)

How about put pageCount into tableOption?

— Reply to this email directly, view it on GitHubhttps://github.com/TanStack/table/issues/4918#issuecomment-1595057486, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AY3LVOCEJK3TOPKG63VXU6DXLSNWPANCNFSM6AAAAAAZI2TZVQ. You are receiving this because you authored the thread.Message ID: @.***>

lakshmanang avatar Jun 17 '23 04:06 lakshmanang

I am using vue-table, also facing the same issue, I am not sure is this bug or I have configured incorrectly?

chiragparekh avatar Jun 22 '23 08:06 chiragparekh

Also same issue! just wasted half a day trying to figure out what I'm doing wrong, but I think it's a bug.

In: Pagination.ts It seems that setPageCount is using setPagination() and updates the count on the PaginationState, from the docs it doesn't look like the pageCount is part of the PaginationState, should be updated directly into table.options.pageCount.

Can someone from tanstack team please take a look? this is a show stopper bug, and no reply on this thread for over a month.

image

Thank you!! 🙏🙏🙏

eyal-rp avatar Jul 18 '23 08:07 eyal-rp

This is actually a really easy fix.. Replacing in the above function 'setPagination' to 'setOptions' fixes the issue, I'll open a PR for this.

eyal-rp avatar Jul 18 '23 09:07 eyal-rp

Appreciate your work on this, @eyal-rp! Any timeline on when this PR will get merged @tannerlinsley? This is a blocking bug for my team and I. Thanks!

sameckmeier avatar Sep 15 '23 22:09 sameckmeier

This is an issue I'm still having, do you happen to have any updates on it?

AndreasMarkopoulos avatar Feb 03 '24 17:02 AndreasMarkopoulos

+1 Having this issue

dogukanoksuz avatar Mar 15 '24 13:03 dogukanoksuz

table.setPageCount is actually a deprecated API that does nothing in v8. Just pass in the page count or row count as a table option. This API was supposed to have been removed by the time v8 stable came out, but it was forgotten about.

KevinVandy avatar Mar 15 '24 14:03 KevinVandy