You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
815 B
42 lines
815 B
<?php
|
|
namespace App\Admin\Extensions;
|
|
|
|
use Dcat\Admin\Grid\RowAction;
|
|
|
|
class CheckRow extends RowAction
|
|
{
|
|
|
|
public function title()
|
|
{
|
|
return 'Check row';
|
|
}
|
|
/**
|
|
* 添加JS
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function script()
|
|
{
|
|
return <<<JS
|
|
$('.grid-check-row').on('click', function () {
|
|
|
|
// Your code.
|
|
console.log($(this).data('id'));
|
|
|
|
});
|
|
JS;
|
|
}
|
|
public function html()
|
|
{
|
|
// 获取当前行数据ID
|
|
$id = $this->getKey();
|
|
|
|
// 获取当前行数据的用户名
|
|
$username = $this->row->username;
|
|
|
|
// 这里需要添加一个class, 和上面script方法对应
|
|
$this->setHtmlAttribute(['data-id' => $id, 'email' => $username, 'class' => 'grid-check-row']);
|
|
|
|
return parent::html();
|
|
}
|
|
}
|