You can get the data for the current row by $actions parameter passed in:
$grid->actions(function ($actions) {// the array of data for the current row $actions->row;// gets the current row primary key value $actions->getKey();});
If you have a custom action button, you can add the following:
$grid->actions(function ($actions) {// append an action. $actions->append('<a href=""><i class="fa fa-eye"></i></a>');// prepend an action. $actions->prepend('<a href=""><i class="fa fa-paper-plane"></i></a>');});
Custom actions
Starting with v1.7.3, the following documents are deprecated, . please use Custom actions instead.
If you have more complex actions, you can refer to the following ways:
First define the action class:
<?phpnamespaceApp\Admin\Extensions;useEzadev\Admin\Admin;classCheckRow{protected $id;publicfunction__construct($id) {$this->id = $id; }protectedfunctionscript() {return<<<SCRIPT$('.grid-check-row').on('click', function () { // Your code. console.log($(this).data('id'));});SCRIPT; }protectedfunctionrender() {Admin::script($this->script());return"<a class='btn btn-xs btn-success fa fa-check grid-check-row' data-id='{$this->id}'></a>"; }publicfunction__toString() {return$this->render(); }}