hide one column in gridview

hi!

I have one problem with one column in a gridview, I want aplicate de parameter "visible" in function with one value from other model, for this I create one function in a model




public function getVisible(){

          

           $model = new TbEntiPerServicio;

           $mostrar = false;          

           $valor1 = $this->ID_SERVICIO; //number of service

           $valor2 = $this->iDSERVICIO->VISIBLE; //state of the service coming from other model relationated

           $valor3 = $this->iDSERVICIO->ID_SERVICIOS; //number of service from the other model relationated

           

           if ($valor1 == $valor3 && $valor2 == 1){

                 $mostrar = true;

                    return self:: $mostrar;

            }

        }



and in the gridview I have this




array (

                                

         'name'=>'ID_SERVICIO',

         'value'=>'CHtml::link($data["1"],Yii::app()->createUrl("/TbEntiPerServicio/detalleview", array("id"=>$data["ID_ENTI_PER_SERV"],"id_entidad"=>$data["ID_ENTI"],"id_servicio"=>"1")))',

                                //'value'=>'$data["1"]',

                                'visible'=>'$data->getVisible()', //this option for hide the column 

                                'type'=>'raw',

                               ),




where is the problem?, because don’t happens nothing, I tray and tray …

thanks a lot!, and sorry for my english

In your function getVisible()… you have a local variable $mostrar… but when returning you have return self::$mostrar… and also the return is executed only inside the if condition… so your method should be like


public function getVisible()

{

   $model = new TbEntiPerServicio;

   $mostrar = false;          

   $valor1 = $this->ID_SERVICIO; //number of service

   $valor2 = $this->iDSERVICIO->VISIBLE; //state of the service coming from other model relationated

   $valor3 = $this->iDSERVICIO->ID_SERVICIOS; //number of service from the other model relationated

   		

   if ($valor1 == $valor3 && $valor2 == 1){

      $mostrar = true;

   }

   return $mostrar;

}



Hi! Maurizio

tanks a lot for you answer and your time.

I will try this.