yii booster checkbox doesn't show boxes to check

853 Views Asked by At

I add the checkbox functionality from the yii-booster. But the widget renders the model view without the needed boxes. What's wrong?

Widjet code in view

<?php
$this->widget('bootstrap.widgets.TbExtendedGridView',array(
'id'=>'docs-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'type'=>'bordered condensed',
'template' => "{items}",
'bulkActions' => array(
    'actionButtons' => array(
        array(
                'buttonType' => 'button',
                'type' => 'primary',
                'size' => 'small',
                'label' => 'Choose',
                'click' => 'js:function(values){console.log(values);}'
                )
            ),
            // if grid doesn't have a checkbox column type, it will attach
            // one and this configuration will be part of it
        'checkBoxColumnConfig' => array(
        'name' => 'id'
        ), 
  ),    
));
2

There are 2 best solutions below

0
On BEST ANSWER

the problem has been in the wrong hierarchy from the example: The 'checkBoxColumnConfig' attribute must be outside of the 'actionButtons' attribute:

'bulkActions' => array(
    'actionButtons' => array(
        /*array(
                'buttonType' => 'button',
                'type' => 'primary',
                'size' => 'small',
                'label' => 'Выбрать отмеченные',
                'click' => 'js:function(values){console.log(values);}'
                )
            ),*/
            // if grid doesn't have a checkbox column type, it will attach
            // one and this configuration will be part of it

    ), 
    'checkBoxColumnConfig' => array(
        'name' => 'id'
        ), 
...
));

but now the widget doesn't work when i uncomment the array part inside 'actionButtons':

 array(
                'buttonType' => 'button',
                'type' => 'primary',
                'size' => 'small',
                'label' => 'Выбрать отмеченные',
                'click' => 'js:function(values){console.log(values);}'
                )

what might be a cause?

1
On

If you are using bulkActions, you have to use 'columns' to list out the columns you want to display instead of using 'template'.

'columns' => array(
    'id',
    'title', 
    ...
),