链街Dcat后台
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

  1. <?php
  2. namespace App\Admin\Extensions;
  3. use Dcat\Admin\Grid\RowAction;
  4. class CheckRow extends RowAction
  5. {
  6. public function title()
  7. {
  8. return 'Check row';
  9. }
  10. /**
  11. * 添加JS
  12. *
  13. * @return string
  14. */
  15. protected function script()
  16. {
  17. return <<<JS
  18. $('.grid-check-row').on('click', function () {
  19. // Your code.
  20. console.log($(this).data('id'));
  21. });
  22. JS;
  23. }
  24. public function html()
  25. {
  26. // 获取当前行数据ID
  27. $id = $this->getKey();
  28. // 获取当前行数据的用户名
  29. $username = $this->row->username;
  30. // 这里需要添加一个class, 和上面script方法对应
  31. $this->setHtmlAttribute(['data-id' => $id, 'email' => $username, 'class' => 'grid-check-row']);
  32. return parent::html();
  33. }
  34. }