SelGridView extension doesn't hold my selected checkboxes

I am using Yii 1.x with the selgridview extension which simply remembers selected rows when sorting or paging. The demo here demonstrates exactly what this does -

I have followed the instructions and while it does work, it doesn’t work 100% as per the demo above.

I have a grid which has 21 rows which spans over 3 pages in the pager (e.g 10 rows per page).

When I attempt to select an checkbox & then go to another page in the pager and then go back to the initial checkbox it is no longer checked.

For instance if I select checkbox ‘4’ on page 1, then navigate to the 3 page in the pager and then return back to page 1 the checkbox 4 is no longer checked (even though I just checked this). I have the ‘checked’ parameter in the widget pulling in an array of pre-selected checkboxes. This is just a standard array e.g Array ( [0] => 5454 [1] => 11402 [2] => 11481 )

This will simply pre-select a number of checkboxes on page load (this element works fine), I cannot understand why when I check a checkbox and navigate to another page of the grid recordset it loses the selection I have just made.

My $_GET request appears as follows:[]=11395&teachers-grid_sel[]=11402

Could anyone provide any advice? Please let me know if my query is unclear i’d be happy to expand further

I am using Yii version 1.1.14

// form view below

            <div class="controls">

            <?php $this->widget('ext.selgridview.BootSelGridView',array(

                'id'			=> 'teachers-grid',

                'type'			=> 'striped bordered condensed',

                'dataProvider' => new CArrayDataProvider($model->getAvailableTeachers(), array(

                   'keyField' => 'user_id'


                'selectableRows' => true,

                'columns' => array(


                        'id' => 'user_id',

                        'class' => 'CCheckBoxColumn',

                        'checked' => 'in_array($data->user_id, $this->grid->owner->model->teacher_ids)',

                        'checkBoxHtmlOptions' => array(

                            'name' => get_class($model)."[teachers][]"






            )); ?>


Does this happen if you remove ‘checked’ key?

Thanks for the reply Bizley, I just removed the following line but the same issue occurs

'checked' => 'in_array($data->user_id, $this->grid->owner->model->teacher_ids)',

I have noticed for some reason in my $_GET request the page parameter isn’t being passed for some reason… could this be a reason for it not working and if so how to get it back in the request

I think you have got ‘urlFormat’ => ‘path’ in your urlManager config.

If so, could you remove it and check this grid again?

I have checked the config in my main.php and does have ‘path’ in the urlFormat, I am unable to remove this option currently as it breaks the custom CMS module so i’ll have to play around with the options within urlFormat and come back.

Would I be correct in stating that this extension will not function when using the ‘path’ url format set in the urlManager within the Yii configuration? If this is the case - is there any simple solution that will allow me to still use the ‘path’ setting in my urlFormat. This is purely due to how the rest of the application is setup.

This shouldn’t be a problem, the page parameter should be correctly passed. I was asking because there might be something broken inside this extension. It would be good to contact the autor or check with others who are using it.

I’ve contacted the author hopefully i’ll get a response soon. I added the following javascript to the page, on a button click it looks at the grid and gets all the selected keys and displays them in the console.log.

For some reason in the console.log it only shows those keys that are actually visible - so for instance if I’m on the first page of pager and have a row from the second page of the pager pre-selected it doesn’t actually recognise this.

It’s almost like the script can only recognise the selected checkboxes that are physically actually visible on the page, any others aren’t seen (regardless if they are checked or not)

    $( document ).ready(function() {


            var teacher_selected = $("#teachers_grid").selGridView("getAllSelection");