Hi all,
I trying to add the onClick functionality to the rows in an IndexTable but having no success.
The index table has the bulk select ability as well.
In short, I’m trying to replicate the behaviour you can see on the Shopify Orders page for a store.
Basically, if you click on anywhere on the row, the order details page appears. However, if you click on the checkbox, the bulk select options appear.
What I have is if you click on where in the row, the bulk select option appears.
I’d like to replicate the behaviour in the orders page.
Below is my IndexTable code and rowMarkup.
<IndexTable
resourceName={resourceName}
promotedBulkActions={promotedBulkActions}
itemCount={packages.length}
selectedItemsCount={
allResourcesSelected ? 'All' : selectedResources.length
}
onSelectionChange={handleSelectionChange}
headings={[
{title: 'Package Name'},
{title: 'Height'},
{title: 'Width'},
{title: 'Depth'},
{title: 'Max Weight (g)'},
]}
>
{rowMarkup}
</IndexTable>
const rowMarkup = packages.map(
({id, packageName, height, width, depth, maxWeight}, index) => (
<IndexTable.Row
id={id}
key={id}
selected={selectedResources.includes(id)}
position={index}
>
<IndexTable.Cell>
<TextStyle variation="strong">{packageName}</TextStyle>
</IndexTable.Cell>
<IndexTable.Cell>{height}</IndexTable.Cell>
<IndexTable.Cell>{width}</IndexTable.Cell>
<IndexTable.Cell>{depth}</IndexTable.Cell>
<IndexTable.Cell>{maxWeight}</IndexTable.Cell>
<IndexTable.Cell><Button onClick={() => alert("Edited")}>
Edit
</Button></IndexTable.Cell>
</IndexTable.Row>
),
);
Much appreciate your help.