nareboy
(Felipe Moreira)
July 6, 2012, 2:03pm
1
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!
rudenich
(Rudenich)
July 6, 2012, 2:30pm
2
The ‘visible’ value can’t be evaluated
Bianca
(Biancajsen)
July 6, 2012, 3:11pm
3
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!
Could it be that ‘visible’ is always being evaluated as true? Change your condition to <> to see if it changes.
nareboy
(Felipe Moreira)
July 6, 2012, 3:45pm
4
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.
mdomba
(Maurizio Domba Cerin)
July 6, 2012, 9:46pm
7
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
softark
(Softark)
July 7, 2012, 2:32am
8
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" : ""',
),
nareboy
(Felipe Moreira)
July 9, 2012, 4:38pm
9
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.
softark
(Softark)
July 9, 2012, 10:37pm
10
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?
nareboy
(Felipe Moreira)
July 10, 2012, 1:11pm
11
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!
nath-0
(Nathalie Chabert)
December 5, 2012, 4:10pm
12
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
softark
(Softark)
December 6, 2012, 4:18pm
13
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".