Set CGridView checkbox via code

Hello, i need to check some checkbox in my CGridView via code.

I have an array in my view and if ID of gridview record is in this array - this record must be checked.

Here is my view code:




//$arr is recieved from controller ($arr = model()->findAllByAttributes(...))

$this->widget('bootstrap.widgets.BootGridView', array(

        'dataProvider' => $mydata,

        'selectableRows' => 2,

        'columns'=>array(

            array(

                'class' => 'CCheckBoxColumn',

                'checked'=> 'MyModel::isRecordInArray($data->ID, $arr)',

            )

        ),

    ));



And model code:




    public static function isEmployeeInProject($id, $arr){

        foreach($arr as $a){

            if ($a->ID == $id) return true;

        }

        return false;

    }



The problem is that the array ($arr) is not passed to the function.

I know about this method but i don’t know, how can I transfer my array in the function

Hi,

you can put $arr in static var of model:




 public static function isEmployeeInProject($id){

        foreach(self::$arr as $a){

            if ($a->ID == $id) return true;

        }

        return false;

    }



Maybe not the best solve, but it works. Thanx!