Hide link/button in table based on column value #2859
-
I have a table that lists book and there is an action dropdown on each row that shows multiple buttons like edit, delete and issue book etc. I want to hide/show the button on a specific row based on the value of the column. For e.g. I want to hide the Issue Book button on the rows which have status "issued" Here is the sample code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To hide or show a button based on the value of a column, you can use the // This button will always be hidden
Button::make('issue')->canSee(false);
// This button will be visible only if the status is not 'issued'
Button::make('issue')->canSee($model->status !== 'issued'); These examples demonstrate how you can manage the visibility of buttons based on values in your model. This is explained in more detail in the documentation for fields, but you can use this method in other places as well, such as fields, links, or layouts. |
Beta Was this translation helpful? Give feedback.
To hide or show a button based on the value of a column, you can use the
canSee
method. This method allows you to control the visibility of elements based on specific conditions. Here are a few simple examples without encapsulation:These examples demonstrate how you can manage the visibility of buttons based on values in your model.
This is explained in more detail in the documentation for fields, but you can use this method in other places as well, such as fields, links, or layouts.