Griddle
Griddle copied to clipboard
Delete row popup, pass function to component
Griddle version
1.13.1
Expected Behavior
Grid has 2 columns with item id and item name. Click on a link in the column with the id. The link contains the item id. Popup opens and asks if you really want to delete this item and shows item name.
I want to pass the item id, item name and the function to delete the item to the custom component. Before the item gets deleted it should show a popup. What is the best way to pass the function?
currently I can only pass the data row as shown in example
const data = [
{
"name": "Mayer Leonard",
"city": "Kapowsin"
},
{
"name": "Koch Becker",
"city": "Johnsonburg"
}
];
<Griddle
data={data}
plugins={[plugins.LocalPlugin]}
components={{
Layout: ({ Table }) => <Table />
}}
pageProperties={{
pageSize: 2
}}
>
<RowDefinition>
<ColumnDefinition
id="name"
title="Persons"
customComponent={enhancedWithRowData(MyCustomComponent)}
/>
</RowDefinition>
</Griddle>
Custom component
const MyCustomComponent = (value, griddleKey, rowData) {
return (
<div>
<a className="action" src={{`/test/delete/${value}/`}} onClick={call passed funtion?}>Delete</a>
</div>
);
}
I created a custom component and passed the function in the extradata. Maybe the documentation about the extradata could be a bit more comprehensive.