tofu2000
(Rob828)
November 26, 2010, 1:23pm
1
Hi,
how can I hide values in CGridView ??
I already tried to hide a column like this:
'htmlOptions'=>array('style'=>'display:none'),
it works but the Column header is still visible.
then I tried to put values into hidden fields inside a template:
'class'=>'CButtonColumn',
'template'=>'{myButton}<input type="hidden" name="hid" value="'.$data->hid.'">',
but at this point the $data->hid is empty. WHY?
thx in advance.
zaccaria
(Matteo Falsitta)
November 26, 2010, 1:38pm
2
$data has a meaning only in some property, for example il CDataColumn::value.
Try in some column to use:
'value'=>'$data-> field <input type="hidden" name="hid" value="'.$data->hid.'">'
'tyle'=>'row'
Type row will avoid html encoding of the cell.
tofu2000
(Rob828)
November 26, 2010, 2:50pm
3
i could do something like this:
array(
'type'=> 'raw',
'value'=> 'CHtml::hiddenField("hid", $data->tarif_id)',
),
but then there’s an empty cell,
and i dont know how to add an additional value next to the hidden field.
Hi tofu2000,
I have done it using following method
array(‘type’=>‘raw’,
'value'=>'CHtml::hiddenField("BulkDeleteForm[$data->filed]",false,array(\'value\'=>$data->value))',
[b]'htmlOptions'=>array([color="#FF0000"]'style'=>'width:0%; display:none'[/color]),[/b]
[b]'headerHtmlOptions'=>array([color="#FF0000"]'style'=>'width:0%; display:none')[/color]),[/b]
It worked without displaying any column header.
Thank you,
Yohan
re1nald0
(Reinld17)
July 10, 2011, 7:54am
6
array(‘type’=>‘raw’,
'value'=>'CHtml::hiddenField("BulkDeleteForm[$data->filed]",false,array(\'value\'=>$data->value))',
[b]'htmlOptions'=>array([color="#FF0000"]'style'=>'width:0%; display:none'[/color]),[/b]
[b]'headerHtmlOptions'=>array([color="#FF0000"]'style'=>'width:0%; display:none')[/color]),[/b]
This works if we have a few hidden columns. However, when there are many hidden columns, the CGridView becomes like this:
As you can see, there is a blank space on the right part of it. Does someone have alternative solution to hide CGridView column (without losing its value)?
kwijanto
(Kw Acong)
August 18, 2011, 3:46am
7
Try this… there should no more blank space on the hidden column.
array('type'=>'raw',
'value'=>'CHtml::hiddenField("BulkDeleteForm[$data->filed]",false,array(\'value\'=>$data->value))',
'header'=>false,
'filter'=>false,
'htmlOptions'=>array('style'=>'width:0%; display:none'),
re1nald0
(Reinld17)
August 26, 2011, 5:31am
8
Try this… there should no more blank space on the hidden column.
array('type'=>'raw',
'value'=>'CHtml::hiddenField("BulkDeleteForm[$data->filed]",false,array(\'value\'=>$data->value))',
'header'=>false,
'filter'=>false,
'htmlOptions'=>array('style'=>'width:0%; display:none'),
Hi,
Thanks for your reply, but I had tried that before and got the same result. Perhaps the solution is to use 1 hidden column, as described in this thread.
ande_zake
(ande zake)
December 31, 2012, 11:54am
9
Hi tofu2000,
I have done it using following method
array(‘type’=>‘raw’,
'value'=>'CHtml::hiddenField("BulkDeleteForm[$data->filed]",false,array(\'value\'=>$data->value))',
[b]'htmlOptions'=>array([color="#FF0000"]'style'=>'width:0%; display:none'[/color]),[/b]
[b]'headerHtmlOptions'=>array([color="#FF0000"]'style'=>'width:0%; display:none')[/color]),[/b]
It worked without displaying any column header.
Thank you,
Yohan
Hello, I am newbie in yii…
tx for the solution …
it work …
mshakeel
(Mshakeel100)
January 4, 2013, 6:45am
10
We need to have hidden fields in our columns for id columns in the database which can be accessible in the $_REQUEST so database can be manipulated. For this there is a simple solution which is as follows:
In any column which is visible to user one can have many hidden fields using the concatenation operator:
array(
'header'=>'75%',
'name'=>'field_name',
'type'=>'raw',
'value'=>
'CHtml::hiddenField(\'array_available_in_request[\'.$row.\']["id"]\', $data["id"]) .
CHtml::hiddenField(\'array_available_in_request[\'.$row.\']["parent_id"]\', $data["ParentId"]) .
CHtml::textField(\'array_available_in_request[\'.$row.\']["field_name"]\', $data["field_name"], array("style"=>"width:50px;"));'
),
I found this worked for me.
Just wanted to hide the id column but still wanted to be able to click on the row and go to the record view
array(
'name' => 'id',
'type'=> 'raw',
// 'value'=> 'CHtml::hiddenField("id", $data->id)',
'value'=> '$data->id',
// 'header'=>false,
// 'filter'=>false,
'headerHtmlOptions'=>array('style'=>'width:0%; display:none'),
'filterHtmlOptions'=>array('style'=>'width:0%; display:none'),
'htmlOptions'=>array('style'=>'width:0%; display:none'),
),
The key was the filterHtmlOptions…before adding that it seemed to have a shift in the columns / filters and headers so
they did not match up.