Yii Framework Forum: hidden values in CGridView - Yii Framework Forum

Jump to content

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

hidden values in CGridView Rate Topic: -----

#1 User is offline   tofu2000 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 04-November 10

Posted 26 November 2010 - 08:23 AM

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

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 26 November 2010 - 08:38 AM

$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.
0

#3 User is offline   tofu2000 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 04-November 10

Posted 26 November 2010 - 09:50 AM

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

#4 User is offline   Yohan Hirimuthugoda 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 11-January 11
  • Location:Sri Lanka

Posted 11 January 2011 - 04:52 AM

Hi tofu2000,

I have done it using following method

array('type'=>'raw',
'value'=>'CHtml::hiddenField("BulkDeleteForm[$data->filed]",false,array(\'value\'=>$data->value))',
'htmlOptions'=>array('style'=>'width:0%; display:none'),
'headerHtmlOptions'=>array('style'=>'width:0%; display:none')),

It worked without displaying any column header.

Thank you,
Yohan
1

#5 User is offline   marrullas 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 03-March 10

Posted 21 June 2011 - 09:26 PM

tnx works!!!
0

#6 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 309
  • Joined: 10-November 10
  • Location:Cimahi

Posted 10 July 2011 - 02:54 AM

View PostYohan Hirimuthugoda, on 11 January 2011 - 04:52 AM, said:

array('type'=>'raw',
'value'=>'CHtml::hiddenField("BulkDeleteForm[$data->filed]",false,array(\'value\'=>$data->value))',
'htmlOptions'=>array('style'=>'width:0%; display:none'),
'headerHtmlOptions'=>array('style'=>'width:0%; display:none')),

This works if we have a few hidden columns. However, when there are many hidden columns, the CGridView becomes like this:

Posted Image

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)?
0

#7 User is offline   Shutter Blazz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-August 11

Posted 17 August 2011 - 10:46 PM

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'),

0

#8 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 309
  • Joined: 10-November 10
  • Location:Cimahi

Posted 26 August 2011 - 12:31 AM

View PostShutter Blazz, on 17 August 2011 - 10:46 PM, said:

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

#9 User is offline   ande zake 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 31-December 12

Posted 31 December 2012 - 06:54 AM

View PostYohan Hirimuthugoda, on 11 January 2011 - 04:52 AM, said:

Hi tofu2000,

I have done it using following method

array('type'=>'raw',
'value'=>'CHtml::hiddenField("BulkDeleteForm[$data->filed]",false,array(\'value\'=>$data->value))',
'htmlOptions'=>array('style'=>'width:0%; display:none'),
'headerHtmlOptions'=>array('style'=>'width:0%; display:none')),

It worked without displaying any column header.

Thank you,
Yohan


Hello, I am newbie in yii...
tx for the solution ...
it work ...
0

#10 User is offline   mshakeel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 04-January 13

Posted 04 January 2013 - 01:45 AM

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;"));'
        ),

1

#11 User is offline   AustinGeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 22-September 12

Posted 28 May 2013 - 11:43 AM

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.
1

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