I'm having trouble identifying selected rows with a checkbox in prime React. the structure of the table is as follows: (the column with the checkbox most be "Visible?").
<div className="col-12">
<DataTable value={variableOptions} editMode = "cell" className="editable-cells-table"
dataKey="_id" paginator rows={10} rowsPerPageOptions={[5, 10, 25]}
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} products" header={"Variables"} responsiveLayout="scroll">
<Column field="name" header="Nombre" sortable />
<Column field="units" header="Unidad" sortable />
<Column field="isPrincipal" header="Gerarquia" sortable />
<Column field="isVisible" header="Visible?" sortable onClick={(e) => bodyCheckBoxVisible(e)}/>
</div>
and the function where i have return the checkbox
const bodyCheckBoxVisible = (e) => {
return ( <Checkbox inputId="binary" checked={checked} onChange={e => setChecked(e.checked)} />)
}
The problem is that the function does not return the checkbox inside the table row.
- How to solve this?
- once the checkbox is shown I must be able to select more than one row because more than one variable can be visible or not, I don't know how to do this function either.
each row has a name and id that identify them, once identified making the change is not difficult I imagine