I have noticed that we can only declare an action disabled with true/false :
actions = [
{
icon: "arrow_upward",
disabled: true,
onClick: (e, row) => this.handleUp(e, row)
}
]
I would like to disable it depending on a condition on the row data, something like this :
actions = [
{
icon: "arrow_upward",
tooltip: "Move up",
disabled: row => row.tableData.id === 0,
onClick: (e, row) => this.handleUp(e, row)
}
]
Is it possible ?
Thank you very much.
Yes it is possible to return action data completely according to rowData:
actions = [
rowData => ({
icon: "arrow_upward",
tooltip: "Move up",
disabled: rowData => rowData.tableData.id === 0,
onClick: (e, row) => this.handleUp(e, row)
})
]
Look at this:
https://mbrn.github.io/material-table/#/docz-examples-03-example-actions
More Actions 2.icon
Thank you !
I forgot about this.
It solves my problem so this feature I proposed is not needed I think.
There are something wrong in the code. it's not correct to put function in the disabled property.
So the correct code is in the below.
actions = [
rowData => ({
icon: "arrow_upward",
tooltip: "Move up",
disabled: rowData.tableData.id === 0,
onClick: (e, row) => this.handleUp(e, row)
})
]
Most helpful comment
Yes it is possible to return action data completely according to rowData:
Look at this:
https://mbrn.github.io/material-table/#/docz-examples-03-example-actions
More Actions 2.icon