Argument 1 passed to yii\base\View::{closure}() must be an instance of Category, instance of common\models\Category given
<?=
GridView::widget([
'dataProvider' => $dataProvider,
//'filterModel' => $searchModel,
'summary' => false,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
[
'class' => 'yii\grid\CheckboxColumn',
'checkboxOptions' => function () {
return [
'onchange' => 'var keys = $("#grid").yiiGridView("getSelectedRows");
$(this).parent().parent().toggleClass("danger")'
];
},
],
//'id',
'slug',
'name',
'title',
'meta_descriptions:ntext',
//'status',
//'user_id',
//'tree_id',
//'created_at',
//'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
]);
?>
$("#delete-select").on("click", function(e){
e.preventDefault()
var keys = $("#grid").yiiGridView("getSelectedRows");
$.ajax({
url: "'. \yii\helpers\Url::toRoute('delete') .'",
type: "POST",
data: {id: keys},
success: function(){
alert("yes")
}
})
});
[
'class' => 'yii\grid\CheckboxColumn',
'checkboxOptions' => function () {
return [
'onchange' => 'var keys = $("#grid").yiiGridView("getSelectedRows");
$(this).parent().parent().toggleClass("danger")'
];
},
],
getSelectedRows: function () {
var $grid = $(this);
var data = gridData[$grid.attr('id')];
var keys = [];
if (data.selectionColumn) {
$grid.find("input[name='" + data.selectionColumn + "']:checked").each(function () {
keys.push($(this).parent().closest('tr').data('key'));
});
}
return keys;
},
<?= Html::submitButton('Удалить выбранные', ['class' => 'btn btn-success', 'id' => 'delete-select']) ?>
TypeError: data is undefinedyii.gridView.js:207:17
getSelectedRows site.local/backend/web/assets/a18f8ac7/yii.gridVie...
yiiGridView site.local/backend/web/assets/a18f8ac7/yii.gridVie...
onchange site.local/backend/web/index.php?r=category:2
jQuery 6
setSelectionColumn site.local/backend/web/assets/a18f8ac7/yii.gridVie...
jQuery 2
'superadmin' => [
'type' => 1,
'description' => 'SuperAdmin',
'children' => [
'moderator',
],
],
'moderator' => [
'type' => 1,
'description' => 'Менеджер',
'children' => [
'user',
],
],
'user' => [
'type' => 1,
'description' => 'User',
],
array(3) {
["superadmin"]=>
object(yii\rbac\Role)#132 (7) {
["type"]=>
int(1)
["name"]=>
string(10) "superadmin"
["description"]=>
string(10) "SuperAdmin"
["ruleName"]=>
NULL
["data"]=>
NULL
["createdAt"]=>
int(1571631152)
["updatedAt"]=>
int(1571631152)
}
["moderator"]=>
object(yii\rbac\Role)#134 (7) {
["type"]=>
int(1)
["name"]=>
string(9) "moderator"
["description"]=>
string(16) "Менеджер"
["ruleName"]=>
NULL
["data"]=>
NULL
["createdAt"]=>
int(1571631152)
["updatedAt"]=>
int(1571631152)
}
["user"]=>
object(yii\rbac\Role)#135 (7) {
["type"]=>
int(1)
["name"]=>
string(4) "user"
["description"]=>
string(4) "User"
["ruleName"]=>
NULL
["data"]=>
NULL
["createdAt"]=>
int(1571631152)
["updatedAt"]=>
int(1571631152)
}
}