I'm looking at customizing the header 'select all' checkbox in react-data-table-component.
<DataTable />
I'm using React 16.14 and using Class components.
Goal: Adding a dropdown when the select all is clicked to add a sub menu of 'Select all on this page' and 'Select all pages'
I see where adding selectableRowsComponent and creating a const with the custom checkbox will update every checkbox for the table, including the select all but that doesn't achieve what I'm looking for.
Looking through documentation I'm not finding anything to update the select all only. Does anyone know of a prop that allows changes to only the header select all checkbox?
<DataTable
columns={this.tableConfig.columns}
data={this.state.data}
theme="dark"
keyField="_id"
fixedHeader={true}
fixedHeaderScrollHeight={tableHeight}
highlightOnHover={true}
customStyles={myStyles}
sortServer={true}
onSort={this.onSort}
selectableRows={this.state.selectableRows}
// selectableRowsComponent={selectAllCustom}
onSelectedRowsChange={this.onSelectedDocument}
selectableRowsVisibleOnly={true}
/>
To customize the "Select All" checkbox in the header of the react-data-table-component component, you can use the selectableRowsComponent prop to override the default component used for selection. However, to achieve the desired behavior of adding a dropdown menu, you'll need to create a custom component that handles this logic.Try it like this, let's see if it works:
Create a custom component for the "Select All" checkbox. This component should include a dropdown menu with options "Select All on This Page" and "Select All Pages." For example:
In your main component that contains the DataTable, import the custom component and use it as the selectableRowsComponent:
With this setup, you've created a custom component for the "Select All" checkbox that includes a dropdown menu with the desired options. However, you'll still need to implement the logic to select all rows on the current page or across all pages using the selectAllCurrentPage and selectAllPages functions in the CustomSelectAllCheckbox component. I hope all this helps you