Yii Framework Forum: Extends Cgridview And 'class' => 'echeckboxcolumn', - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Extends Cgridview And 'class' => 'echeckboxcolumn', Rate Topic: -----

#1 User is offline   nath-0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 12-October 12
  • Location:switzerland

Posted 08 January 2013 - 04:36 AM

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 :

Quote

Cannot use object of type ECheckBoxColumn as array in C:\wamp\www\Qges\application\protected\extensions\core\QGridView.php on line 360


Somone know how to do it ?

Nath
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,336
  • Joined: 12-October 09
  • Location:Croatia

Posted 08 January 2013 - 04:41 AM

And what is happening in your extended QGridView at the line 360 ?
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   nath-0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 12-October 12
  • Location:switzerland

Posted 08 January 2013 - 04:51 AM

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;
		}

0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,336
  • Joined: 12-October 09
  • Location:Croatia

Posted 08 January 2013 - 05:05 AM

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...
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   nath-0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 12-October 12
  • Location:switzerland

Posted 08 January 2013 - 08:39 AM

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 :

Quote

Undefined index: class
print_r($column['class']); <<<<


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 !
0

#6 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,336
  • Joined: 12-October 09
  • Location:Croatia

Posted 08 January 2013 - 08:43 AM

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:

Quote

I copy the code from CGridView to QGridView.<br style="color: rgb(28, 40, 55); font-size: 13px; line-height: 19px; background-color: rgb(250, 251, 252);">I just add: Yii::import('zii.widgets.grid.CGridView');


If you copy all the code from CGridView, why do you import the CGridView ?
Find more about me.... btw. Do you know your WAN IP?
0

#7 User is offline   nath-0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 12-October 12
  • Location:switzerland

Posted 08 January 2013 - 08:55 AM

Quote

If you copy all the code from CGridView, why do you import the CGridView ?


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.

This post has been edited by nath-0: 08 January 2013 - 09:12 AM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users