Extends Cgridview And 'class' => 'echeckboxcolumn',

hello,

I extends the CGridView.

I use a extention ‘ECheckBoxColumn’ that I download. I put this extension in application.extensions.core.

I add :




Yii::import('zii.widgets.grid.CGridView');

Yii::import('application.extensions.core.ECheckBoxColumnn');






$this->widget('QGridView', array(// application.extensions.core.GroupGridView  // zii.widgets.grid.CGridView

    'id' => 'tprojets-grid',

    'dataProvider' => $model->search(),

    // 'extraRowColumns' => Yii::app()->user->isAdmin ?array('date'):'',

    'enablePagination' => true,

  //  'add' => true,

    'columns' => array(

        array(

            'class' => 'ECheckBoxColumn',

            'id' => 'ckPourEnvoyer',

            'header' => 'c',

            'disabled' => 'helpers::setCkPourEnvoyer($data->factured,$data->fk_personne)? null : "disabled"',

            'cssClassExpression' => "(\$data->factured) ?  'tdred':''",

            'value' => '$data->rapport_activite_id',

            'selectableRows' => 2,

        ),

...



In my extensiotn QGridView.

And I get this error :

Somone know how to do it ?

Nath

And what is happening in your extended QGridView at the line 360 ?




foreach($this->columns as $i=>$column)

		{

			if(is_string($column))

				$column=$this->createDataColumn($column);

			else

			{

				if(!isset($column['class']))    <<<<<<< line 360

					$column['class']='CDataColumn';

				$column=Yii::createComponent($column, $this);

			}

			if(!$column->visible)

			{

				unset($this->columns[$i]);

				continue;

			}

			if($column->id===null)

				$column->id=$id.'_c'.$i;

			$this->columns[$i]=$column;

		}



Seems that at the line 360 you get an object instead of an array…

As you use a custom grid and a custom column it’s difficult to say where could be the problem… you need to debug a bit and see why you get an object there…

To narrow down if the problem is in your grid code or in the column code, you can try to use your extended grid with default Yii columns to see if it works…

I copy the code from CGridView to QGridView.

I just add :


Yii::import('zii.widgets.grid.CGridView');

and to test :




foreach($this->columns as $i=>$column)

		{

            

			if(is_string($column))

				$column=$this->createDataColumn($column);

			else

			{

				if(!isset($column['class'])){

                    echo '<pre>';

            print_r($column['class']);

            echo '</pre>';

            exit();

					$column['class']='CDataColumn';

                }

				$column=Yii::createComponent($column, $this);

			}



I get this error :

aand here the call to the widget :




$this->widget('application.extensions.core.QGridView', array(// application.extensions.core.GroupGridView  // zii.widgets.grid.CGridView

    'id' => 'tprojets-grid',

    'dataProvider' => $model->search(),

    // 'extraRowColumns' => Yii::app()->user->isAdmin ?array('date'):'',

    'enablePagination' => true,

  //  'add' => true,

    'columns' => array(

//        array(

//            'class' => 'ECheckBoxColumn',

//            'id' => 'ckPourEnvoyer',

//            'header' => 'c',

//            'disabled' => 'helpers::setCkPourEnvoyer($data->factured,$data->fk_personne)? null : "disabled"',

//            'cssClassExpression' => "(\$data->factured) ?  'tdred':''",

//            'value' => '$data->rapport_activite_id',

//            'selectableRows' => 2,

//        ),

        array(

            'name' => 'date',

            'value' => '$data->date',

            'htmlOptions' => array('style' => 'text-align: center;width:100px'),

            'cssClassExpression' => "(\$data->factured) ?  'tdred':''",

        ),

        array(

 //           'class' => 'TotalColumn', //'heures', //'footer'=>$provider->itemCount===0 ? '' : $model->getTotals(),

            'name' => 'heures',

            'value' => '$data->heures',

            'type' => 'raw',

            'htmlOptions' => array('style' => 'text-align: center;width:50px'),

            'footer' => true,

        ),

         array(

            'name' =>  'libelle_public',

            'value' => '$data->libelle_public',

            'htmlOptions' => array('style' => 'width:550px'),

        ),

        array(

            'name' => 'projetsActif',

            'value' => '$data->projetsActif->acronyme',

            'header' => 'Projets',

        ),

        array(

            'name' => 'tachesActif',

            'value' => '$data->tachesActif->titre',

            'header' => 'Taches',

        ),

        array(

            'name' => 'facture',

            'type' => 'html',

            'value' => '$data->facture  ? CHtml::image(helpers::evaluateTrick($data->facture)): "" ',

            'htmlOptions' => array('style' => 'text-align: center;width:25px'),

            'header' => 'Facturable',

        ),

        array(

            'name' => 'fk_personne',

            'value' => '$data->personnesActif->NomPersonne',

            'htmlOptions' => array('style' => 'width:125px'),

            'header' => 'Personnes',

        ),

//        array(

//            'class' => 'QButtonColumn',

//            'template' => '{update}{delete}',

//            'deleteButtonUrl' => 'Yii::app()->createUrl("/TRapportsActivites/delete", array("id" => $data->rapport_activite_id))',

//            'buttons' => array(

//                'update' => array(

//                    'visible' => 'helpers::autoriseAction($data->fk_personne) ? true : false',

//                    'url' => '$this->grid->controller->createUrl("/TRapportsActivites/update", array("id"=>$data->rapport_activite_id,"asDialog"=>1,"gridId"=>$this->grid->id))',

//                    'click' => 'function(){$("#frame-Update").attr("src",$(this).attr("href")); $("#form-Update").dialog("open");  return false;}',

//                ),

//                'delete' => array(

//                    'visible' => 'helpers::autoriseAction($data->fk_personne) ? true : false',

//                ),

//            ),

//        ),

    ),

));



if I replace application.extensions.core.QGridView with zii.widgets.grid.CGridView, it’is working !

So with the CGridView it’s working but with your extended grid you get the error?

Then the problem is clearly in your extended grid… you need to check your code to see what is happening there and why you get that error.

You wrote:

[/color][/size]

[size="2"][color="#1c2837"]If you copy all the code from CGridView, why do you import the CGridView ?[/color][/size]

just to test, after when it is working, I will change the code of my QGridView.

Edit :humm I am newbie with POO programation, too. I find why it was not working.