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.
36 lines
672 B
36 lines
672 B
<?php |
|
|
|
namespace Dcat\Admin\Grid; |
|
|
|
abstract class BatchAction extends GridAction |
|
{ |
|
/** |
|
* {@inheritdoc} |
|
*/ |
|
protected function actionScript() |
|
{ |
|
$warning = __('No data selected!'); |
|
|
|
return <<<JS |
|
function (data, target, action) { |
|
var key = {$this->getSelectedKeysScript()} |
|
|
|
if (key.length === 0) { |
|
Dcat.warning('{$warning}'); |
|
return false; |
|
} |
|
|
|
// 设置主键为复选框选中的行ID数组 |
|
action.options.key = key; |
|
} |
|
JS; |
|
} |
|
|
|
/** |
|
* @return string |
|
*/ |
|
public function getSelectedKeysScript() |
|
{ |
|
return "Dcat.grid.selected('{$this->parent->getName()}')"; |
|
} |
|
}
|
|
|