Search code examples
phplaravel-admin

How do you hide the row actions behind the 3 dots in laravel-admin package?


How do you create the row actions to be like this (screen shot from documentation)

enter image description here

To see just 3 dots and click on them and then show the buttons?

This is the laravel package I'm talking about: https://github.com/z-song/laravel-admin

Docs: https://laravel-admin.org/docs/en/


Solution

  • So the answer to this question would be to simply use the

    $grid->setActionClass(Grid\Displayers\DropdownActions::class);
    

    which is enabled by default for laravel-admin in config config/admin.php

    /*
    |------------------------------------------------------------------------ --
    | The global Grid action display class.
    |--------------------------------------------------------------------------
    */
    'grid_action_class' => \Encore\Admin\Grid\Displayers\DropdownActions::class,
    

    But it was commented out in our project meaning it was disabled.

    There is a catch also. If you have custom made RowAction you should use it like this:

    $grid->actions(function ($actions) {
        $actions->add(new CustomRowAction());
    }
    

    namespace App\Admin\Actions\Document;
    
    use Encore\Admin\Actions\RowAction;
    
    class CustomRowAction extends RowAction
    {
        public $name = 'Button name';
    
        public function handle()
        {
            // do something here
        }
    
        public function dialog()
        {
            $this->confirm('Are you sure?');
        }
    }