How do I maintain checkboxes in a checked state while navigating from page to page in a GridView? Also how do I preload checkboxes in a GridView.I would like some of the chekboxes to be checked before the GridView loads. I am using yii2.

Found a way to preload the selected checkboxes. Did it using checkbox options. I pass the ids i want to select to the view via the render method. Below is code showing how I worked with checkboxOptions. $permissions is an array with the ids to be selected. It’s an associative array. The key is the id and the value can be anything you want. Another important point is the use keyword which makes the $permissions variable available to the checkboxOptions closure.

'checkboxOptions'=>function($model,$key,$index,$column) use($permissions){                              





               return ['value'=>$model->id,'checked'=>$checked];                    


If you move to another page and come back the checkbox will still be selected.However, I still haven’t figured out how to ensure that checkbox selections that have not been submitted yet maintain state as we move from page to page in the grid view. Any ideas on this?