Skip to content
Advertisement

yii2 double gridview in a form

I have 2 gridview in a form and from them I have to extract selectedrows, which I did with 'class' => 'kartikgridCheckboxColumn'. In a controller receive the selected values in a selection[] variable.

Here comes the problem. The selection[] variable brings the selection of the 2 gridViews. Ex:

array (size=2) 0 => string ’10’ (length=2) 1 => string ’44’ (length=2)

That result is the selection of one row of each GridView. How can I separate the selection[] results.

Advertisement

Answer

you can make your own column

[
    'header'=>Html::checkbox('selection_all', false, ['class'=>'select-all', 'value'=>1, 'onclick'=>'$(".custom-row-checkbox").prop("checked", $(this).is(":checked"));']),
    'contentOptions'=>['class'=>'custom-row-select'],
    'content'=>function($model, $key){
        return Html::checkbox('selection2[]', false, ['class'=>'custom-row-checkbox', 'value'=>$key]);
    },
    'hAlign'=>'center',
    'vAlign'=>'middle',
    ...
]
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement