react-data-table-component icon indicating copy to clipboard operation
react-data-table-component copied to clipboard

Checkboxes won't stay checked

Open doverradio opened this issue 3 years ago • 0 comments

Having a problem because the checkboxes in my datatable don't remain "checked".

I do see there is indication the check occurred but not seeing it remaining checked: Alt Text

It's weird, right? Why is that happening?

Here's my code:

             <DataTable
                 title={ `Items` }
                 columns={ columns }
                 data={ filteredItems }
                 pagination
                 paginationResetDefaultPage={ resetPaginationToggle_users }
                 subHeader
                 onRowClicked={ handleRowClicked }
                 selectableRows
                 selectableRowsComponent={Checkbox} // Pass the function only
                 selectableRowsComponentProps={selectProps}
                 onSelectedRowsChange={ handleSelectedRows }
                 responsive
                 expandableRows
                 expandOnRowClicked
                 expandableRowsHideExpander
                 expandableRowsComponent={ <UpdateItemComponent data={ mainData } s={ s } setS={ setS } /> }
                 persistTableHead
             />

Perhaps it's something to do with selectableRowsComponent and Checkbox?

Here's how that is being brought into this code:


    const Checkbox = React.forwardRef(({ onClick, ...rest }, ref) =>
    {
     return(
         <>
             <div className="form-check pb-5" style={{ backgroundColor: '' }}>
                 <input 
                     type="checkbox"
                     className="form-check-input"
                     style={{ height: '20px', width: '20px' }}
                     ref={ref}
                     onClick={ onClick }
                     {...rest}
                 />
                 <label className="form-check-label" id="booty-check" />
             </div>
         </>
     )
    })

I am trying to have the checkboxes remain checked.

How to do it?

doverradio avatar Aug 10 '22 19:08 doverradio