php - yii2 double gridview in a form

593

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

Here comes the problem. Theselection[] 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 theselection[] results.

464

Answer

Solution:

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',
    ...
]

People are also looking for solutions to the problem: php - receive returned value by class in oop

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.