Right now, I am using this approach: In the array of objects containing the values of DataTable, I define a field that has the InputSwitch element as follows:
Code: Select all
const data= [
{
id: "1000",
code: "f230fh0g3",
name: "Bamboo Watch",
description: "Product Description",
image: "bamboo-watch.jpg",
price: 65,
category: "Accessories",
quantity: 24,
inventoryStatus: "INSTOCK",
rating: 5,
action: (
<InputSwitch
onChange={(e) => {
console.log(e.target);
}}
/>
),
},...]
Code: Select all
<DataTable value={notificationsData} responsiveLayout="scroll" >
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
<Column field="action" header="Active"></Column>
</DataTable>
Does anyone know a better way to tackle this problem?
Thanks a lot in advance.