I have a problem which have to be easy, but I cant find solution. I have a grid view like this:
echo GridView::widget([
'dataProvider' => $dataProviderCountry,
'filterModel' => $searchModelCountry,
'columns' => [
['class' => 'yii\grid\CheckboxColumn',
'name'=>'check1'],
[ 'attribute' => 'description',
'label' =>'Country',],
['class' => 'yii\grid\ActionColumn', 'template' => '{view}'],
],
]);
I am developing a check all function, so I have a js function for each checkbox, but I need to add one more thing, one you go from one page to other you lose you have check checkboxs in table but dont have them in page, so I need to add onclick action to page number to check the temp table and if the value is in the table to set it like check, but I cant find how to give this propriety to the page numbers because it is done with grid view. Or if you know some other methods to do it it can be good also. This is my js code.
$(function (){
var keys = [];
$(document).on('click','.checkboxCntr',function (){
value= parseInt($(this).val());
console.log($(this).prop('checked'));
if($(this).prop('checked'))
{ keys.push(value);
}
else
{var index = keys.indexOf(value);
if (index > -1) {
keys.splice(index, 1); } } console.log(keys);
}) ;});