This is the use of the Checkboxoptions Marquee
Use Yii\grid\gridview;
$this->registerjs ("
$ (' #selection_all '). Click (function () {
$ (' input[name=selection_all] '). Click ();
});
$ (' #delete_select '). Click (function () {
var selection = $ (' #w0 '). Yiigridview (' getselectedrows ');
if (selection.length==0) {
Alert (' unchecked ');
return false;
}else{
if (Confirm (' Are you sure you want to delete it? ') ==true) {
$.post (' ". Url::to ([' Product-base/delete-select ']). "', {selection:selection}";
Location=location;
}else{
Location=location;
}
}
});
$ (' #up_select '). Click (function () {
var selection = $ (' #w0 '). Yiigridview (' getselectedrows ');
if (selection.length==0) {
Alert (' unchecked ');
return false;
}else{
$.post (' ". Url::to ([' Product-base/status-select ']). "', {selection:selection,status:1}";
Location=location;
}
});
$ (' #down_select '). Click (function () {
var selection = $ (' #w0 '). Yiigridview (' getselectedrows ');
if (selection.length==0) {
Alert (' unchecked ');
return false;
}else{
$.post (' ". Url::to ([' Product-base/status-select ']). "', {selection:selection,status:0}";
Location=location;
}
});
", \yii\web\view::P os_end);
<?= Gridview::widget ([
' Layout ' = ' {items}<div class= ' row ' >
<div class= ' Btn-group col-md-3 ' >
<button class= ' btn btn-warning ' id= ' Selection_all ' > select all </button>
<button class= ' btn btn-default ' id= ' up_select ' > Shelves </button>
<button class= ' btn btn-default ' id= ' down_select ' > Lower shelf </button>
<button class= ' btn btn-default ' id= ' delete_select ' > Delete </button>
</div>
<div class= ' col-md-7 ' style= ' margin-top:-20px ' >
{pager}</div>
</div>
",
' Dataprovider ' = $dataProvider,
' Columns ' = [
[' class ' = ' Yii\grid\serialcolumn '],
[' class ' = ' Yii\grid\checkboxcolumn ',
' Checkboxoptions ' = function ($model, $key, $index, $column) {
return [' Value ' = $model->id];
}],
[' class ' = ' Yii\grid\actioncolumn '],
[
' Label ' = ' More action ',
' Format ' = ' raw ',
' Value ' = function ($model) {
return html::a (' Store Merchandise list ', [' Product/index ', ' id ' = ' + ' $model->id], [' title ' + ' store listings ']);
}
],
],
]);?>
The wording in the controller:
Public Function Actiondeleteselect () {
Delete Selection
$selection = Yii:: $app->request->post (' selection ');
Productbase::d eleteall ([' id ' = ' + $selection]);
}
Change state
Public Function Actionstatusselect () {
Find the selected
$selection = Yii:: $app->request->post (' selection ');
I found the post.
$status = Yii:: $app->request->post (' status ');
Productbase::updateall ([' status ' = ' = ' $status],[' id ' + $selection]);
}
The use of YIi2 in checkboxoptions pre-selection box