问:如何在 CGridView 中隐藏列?
状态:我按照 yii 论坛的帖子隐藏了这里和这里的列。但在我的网格视图中,右栏没有隐藏。它显示为空白。
这是我的视图代码
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'acc-recei-grid',
'dataProvider'=>$model->search_arlist(),
'filter'=>$model,
'columns'=>array(
array('name' => 'acc_category_id',
'value'=>'(isset($data->acccategories->name)) ? CHtml::encode($data->acccategories->name) :""',
'filter'=>CHtml::listData($acccategory, 'id', 'name'),
),
//'customer_id',
//'date',
array('name' => 'job_id',
'value'=>'(isset($data->jobs->name)) ? CHtml::encode($data->jobs->name) :""',
//'filter'=>CHtml::listData($job, 'id', 'name'),
),
array(
'class'=>'CButtonColumn',
'template'=>'{select}',
'buttons'=>array
(
'select' => array
(
'imageUrl'=>Yii::app()->request->baseUrl.'/protected/assets/images/gridview/icon_select.gif',
'options'=>array('style'=>'width:10px; border:none'),
'click'=>'function(){
var itemID = $(this).parents(\'tr\').find(\'.recei-id\').text();
$("#AccPaymentRecei_acc_recei_id").val(itemID);
$("#accreceilist").dialog("close");
}',
),
),
),
array(
'type'=>'raw',
'value'=>'$data->id',
//'filter'=>array('style'=>'visible:none'),
'headerHtmlOptions'=>array('style'=>'width:0px; display:none; border:none; textdecoration:none'),
'htmlOptions'=>array('style'=>'display:none; border:none;', 'class'=>'recei-id'),
'header'=>false,
'filter'=>false,
),
),
)); ?>
但网格视图显示如下
====== 更新
<div id="acc-recei-grid" class="grid-view">
<div class="summary">Displaying 1-1 of 1 result(s).</div>
<table class="items">
<thead>
<tr>
<th id="acc-recei-grid_c0"><a href="/mmaig_ceo/ceo-control-system/accRecei/Accreceilist?AccRecei_sort=acc_category_id">Acc Category</a></th><th id="acc-recei-grid_c1"><a href="/mmaig_ceo/ceo-control-system/accRecei/Accreceilist?AccRecei_sort=job_id">Job</a></th><th class="button-column" id="acc-recei-grid_c2"> </th><th style="width:0px; display:none; border:none; textdecoration:none" id="acc-recei-grid_c3"> </th></tr>
<tr class="filters">
<td><select name="AccRecei[acc_category_id]">
<option value=""></option>
<option value="1">asdfasdf</option>
</select></td><td><input name="AccRecei[job_id]" type="text" maxlength="11" /></td><td> </td><td> </td></tr>
</thead>
<tbody>
<tr class="odd"><td>asdfasdf</td><td>asdf</td><td class="button-column"><a style="width:10px; border:none" class="select" title="select" href="#"><img src="/mmaig_ceo/ceo-control-system/protected/assets/images/gridview/icon_select.gif" alt="select" /></a></td><td style="display:none; border:none;" class="recei-id">1</td></tr>
</tbody>
</table>
<div class="keys" style="display:none" title="/mmaig_ceo/ceo-control-system/AccRecei/Accreceilist"><span>1</span></div>
</div>