Problem with CCheckBoxColumn visible property

Hi guys.

This is my CCheckBoxColumn on cgridview:




array

(

  'header'=>'Aceitar',

  'class'=>'CCheckBoxColumn',

  'id'=>'pontos_aceitos',

  'visible'=>'$data->aceite=="S"? false:true',

),



But the checkbox always get visible. To prove that my data "$data->status_registro" shows correct information, My rowCssClassExpression works perfectly:




'rowCssClassExpression'=>'$data->aceite =="S" ? "gone ". ($row%2 ? "even" : "odd") : ($row%2 ? "even" : "odd")', 



What i’m doing wrong?

Thanks!

The ‘visible’ value can’t be evaluated

Could it be that ‘visible’ is always being evaluated as true? Change your condition to <> to see if it changes.

Yes. The visible property can be evaluated.

This other code in my application works perfectly:




array

(

 	'class'=>'CButtonColumn',

        'template' => '{update}',

        'header'=>'Justificar',

        'buttons' => array(

        'htmlOptions'=>array('style'=>'text-align:right'),   

	'update' => array(

                         'visible'=>'$data->status_registro=="I"? false:true',

                         'label'=>'Imprimir',    

                         'url'=>'',       

                         'imageUrl'=>Yii::app()->request->baseUrl.'/images/justificar.png',  

                         'click'=>'function(link,success,data)

	  {

	data = $(this).parent().parent().children(".dataregistro").text();

	var hora = $(this).parent().parent().children(".hora").text();

	var justificativa = $(this).parent().parent().children(".justificativa").text();

	var hora_retificada = $(this).parent().parent().children(".hora_retificada").text();

	opendialog(data,hora,justificativa,hora_retificada);

											


   ),	

											

						

  ),

),



But the same idea “‘visible’=>’$data->status_registro==“I”? false:true’,” does not work on CCheckBox Column and i dont know why.

Same thing :mellow:

Someone? :-[

By documentation the visible property is "boolean" and is not validated - http://www.yiiframework.com/doc/api/1.1/CGridColumn#visible-detail

In the other example you gave above "visible" is the option of the buttons definition and that one is a PHP expression that is evaluated - http://www.yiiframework.com/doc/api/1.1/CButtonColumn#buttons-detail

I think you can make use of ‘cssClassExpression’ property to control the visibility of the checkbox.

http://www.yiiframework.com/doc/api/1.1/CGridColumn#cssClassExpression-detail




array

(

  'header'=>'Aceitar',

  'class'=>'CCheckBoxColumn',

  'id'=>'pontos_aceitos',

  'cssClassExpression'=>'$data->aceite == "S" ? "hidden" : ""',

),



Thank you very much for your reply softark but it did not work.

The field CCheckBoxColumn still visible. If I can at least disable it like disabled = false, it perfectly fits me.

Have you added an entry for ".hidden" class in your css?

I’m sorry softdark. I had understood that the property was a hidden css not a css class. It worked beautifully, thanks you very much!

humm I am sorry for the question(css aie aie), but how do you write in your file css the rule coresponding to :

class="checkbox-column hidden"

Because when I use :

‘cssClassExpression’=>’$data->aceite == “S” ? “hidden” : “”’,

that renders :

class="checkbox-column hidden"

thanks

NAth

Normally you just have to add the following in your own css file




.hidden {

    display: none;

}



You can ignore "checkbox-column" class which the CCheckBoxColumn will add to the cell.




class="checkbox-column hidden"



means that the element has "checbox-column" class AND "hidden" class. So the element will have the cumulative styles of ".checkbox-column" AND ".hidden".