protected function grid()
{
$grid->tools(function ($tools) {
$tools->batch(function ($batch) {
$batch->add('批量获取ID', new TestActions(1));
});
});
return $grid;
}
2、创建按钮操作php文件TestActions.php
namespace App\Admin\Actions\Test;
use Encore\Admin\Grid\Tools\BatchAction;
use Illuminate\Support\Facades\Auth;
class TestActions extends BatchAction
{
protected $action;
public function __construct($action = 1)
{
$this->action = $action;
}
public function script()
{
return <<<EOT
$('{$this->getElementClass()}').on('click', function() {
var ids = $.admin.grid.selected();
onModalShow('#infoDia