<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>React-Table on Taha Husain</title>
    <link>https://tahahusain.net/tags/react-table/</link>
    <description>Recent content in React-Table on Taha Husain</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 22 Oct 2021 15:12:17 +0530</lastBuildDate>
    <atom:link href="https://tahahusain.net/tags/react-table/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>React Table - How to implement row selection with controlled server-side pagination</title>
      <link>https://tahahusain.net/posts/tech/react-table-row-selection-with-controlled-pagination/</link>
      <pubDate>Fri, 22 Oct 2021 15:12:17 +0530</pubDate>
      <guid>https://tahahusain.net/posts/tech/react-table-row-selection-with-controlled-pagination/</guid>
      <description>&lt;p&gt;In this blog,&#xA;we will implement&#xA;multi-row selection&#xA;and select all&#xA;with controlled&#xA;server-side pagination&#xA;in React&#xA;using React Table hooks.&lt;/p&gt;&#xA;&lt;p&gt;We will use&#xA;examples provided by&#xA;&lt;code&gt;react-table&lt;/code&gt; for&#xA;&lt;a href=&#34;https://react-table.tanstack.com/docs/examples/pagination-controlled&#34;&gt;controlled pagination&lt;/a&gt;&#xA;and&#xA;&lt;a href=&#34;https://react-table.tanstack.com/docs/examples/row-selection-and-pagination&#34;&gt;row selection and pagination&lt;/a&gt;&#xA;and work our way to acheive desired result.&lt;/p&gt;&#xA;&lt;h3 id=&#34;implementation&#34;&gt;Implementation&lt;/h3&gt;&#xA;&lt;h4 id=&#34;step-1&#34;&gt;Step 1&lt;/h4&gt;&#xA;&lt;p&gt;To select all rows,&#xA;we would need unique identifier&#xA;of all rows pre-fetched&#xA;on the page.&#xA;Pass all ids to the &lt;code&gt;Table&lt;/code&gt; component.&lt;/p&gt;&#xA;&lt;h4 id=&#34;step-2&#34;&gt;Step 2&lt;/h4&gt;&#xA;&lt;p&gt;Use &lt;code&gt;getToggleAllRowsSelectedProps&lt;/code&gt;&#xA;instead of &lt;code&gt;getToggleAllPageRowsSelectedProps&lt;/code&gt;&#xA;for header checkbox&#xA;to trigger rows select event across&#xA;all pages.&#xA;Note - &lt;code&gt;getToggleAllRowsSelectedProps&lt;/code&gt; works&#xA;seamlessly for frontend pagination,&#xA;but needs to be customized for&#xA;server-side pagination.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
