Many hidden columns problem in CGridView

What I need to achieve is when users click a row in CGridView, its data (16 columns) is passed to parent window. We can achieve this by making all columns visible, but I have several columns that don’t need to be displayed in CGridView (although they still need to be passed to parent window).

I have tried:



  'headerHtmlOptions'=>array('style'=>’width:0%; display:none'),

  'htmlOptions'=>array('style'=>’width:0%; display:none'),


array (



  'htmlOptions'=>array('style'=>'width:0%; display:none'),

  'headerHtmlOptions'=>array('style'=>'width:0%; display:none')


These works if we have a few hidden columns. However, when there are many hidden columns, the CGridView becomes like the attached picture (there is a blank space on the right part of it).

Does anyone have solution for this?



i don’t know all the details… but if this parent window is anoter http request… it would be better to pass only the primary key of the selected row and then from the controller before rendering the parent window to search that record and get all the data needed…

on the other side… .if you do this all on the client (no http request for the parent)… then you need to play a bit more… again you could get only the PK of the selected row… and all the other data from an ajax call to a specific method only for that…

third solution I can think of is to put all this "additional" data into one column that is hidden, all values separated by some delimiter

would be nice to hear how you solve this…

The parent window is called via Javascript (client side). Initially, I did something like this:

Yii::app()->clientScript->registerScript('row-click', "

$('#material-grid table tbody tr').live('click', function(){

  var parent = window.opener;




Yes, I go with this solution since it is easier than writing additional ajax call. The blank space on right side still appears, but it doesn’t look significant now.

Just post a summary for this (in case someone needs it :) ). The hidden CGridView column becomes somewhat like:










While the script is pretty straightforward:

Yii::app()->clientScript->registerScript('row-click', "

$('#material-grid table tbody tr').live('click', function(){

  var parent = window.opener;

  // get hidden data value (hidden column is the seventh column)

  var data = $(this).children(':nth-child(7)').text().split('|');	







Thank you for your help, mdomba, as always. :)

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:






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