TanStack / table

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
https://tanstack.com/table
MIT License
24.93k stars 3.07k forks source link

Not re-render table after changing pagination #1065

Closed ali-master closed 5 years ago

ali-master commented 6 years ago

Is this a general question about implementation, support, API, or anything else?

I want to change the table content after changing the pagination, and sort functionalities should be works as well by client not server. And I have been written the following code for doing this:

<Table
    page={page - 1}
    data={tableData}
    pages={totalPages}
    loading={!isLoaded}
    minRows={tableData.length}
    columns={this.getColumns()}
    defaultPageSize={sizePerPage}
    onPageChange={this.onPageChange}
    onPageSizeChange={this.onPageSizeChange}
/>

But while I click on Next button, I could receive data, but I couldn't see my data in the table, But it just works as ok on the first page. I if use the onFetchData hook, it will be working as ok, but the sort feature is not working after using this hook.

What version of React-Table are you using?

6.8.5 Your bug may already be fixed in the latest release. Run yarn upgrade react-table! 6.8.5

What bug are you experiencing, or what feature are you proposing?

I can not see my data in the table after changing the pagination by that hooks(My data has from server and client just should handle the sort feature.).

What are the steps to reproduce the issue?

  1. Try to get data from the server with this params 1.1: page = 1 1.2: pageSize = 25 I will receive the number of total pages and data.

  2. I try to render the table with the above config.

  3. I have used the pagination hooks for handling the data by pagination from the server.

  4. If I go to page 2, then I can not see the rendered data in the table and table is empty. But it works on the first page.

ali-master commented 6 years ago

Did not have an answer to my question?

Jaujon commented 6 years ago

Hi Ali, have you read this page of the documentation about server-side pagination & sorting: https://react-table.js.org/#/story/server-side-data The ReactTable component needs a manual property for example. Let me know if you have any trouble with the implementation.

ali-master commented 6 years ago

Yes, @Jaujon,

But sorting features should be managing by the client not the server and just I need manage the table content by changing pagination then call API and put that in the table.

Thank you in advance.

Jaujon commented 6 years ago

@ali-master

ReacTable provides everything necessary to handle server-side pagination & sorting. If your api provides the necessary pagination interface, you are perfectly able to implement it.

ali-master commented 6 years ago

I know @Jaujon,

But as I said in my issue description, the second page does not render my contents, but when I use the manual props, the sort function doesn't work.

migratorAlio commented 6 years ago

manual // Forces table not to paginate or sort automatically, so we can handle it server-side; Putting a prop manual in the can solve this question; Like

tannerlinsley commented 5 years ago

If you use server-side data and the manual prop, your server is responsible for handling all of the pagination, sorting, and filtering on your table. Trying to combine server-side data with client side filtering etc. is very messy and probably a bad idea.

This feature/issue has been tagged as one that will likely be fixed or improved in the next major release of React-Table. This release is expected to be completed in the next 6 - 8 months. Please see #1143 for more detail. If you believe this feature can be easily fixed, we invite you to fork the project, attempt the fix, and use it until the latest version is available. If the fix is simple enough, we will also consider it as a PR to the current version.