我在Yii下用bootstrap.widgets.TbGridView创建了一个包含四列的GridView,就像
|name | age | sex | birthday |
|----------------------------|
|( )|( )|( )|( )|
|----------------------------|
|Lo |1 |f |24/05 |
和()表示搜索框,所以现在我想隐藏年龄的搜索框,使它看起来像这样:
|name | age | sex | birthday |
|----------------------------|
|( )| |( )|( )|
|----------------------------|
|Lo |1 |f |24/05 |
任何人都可以告诉我如何用Yii做到这一点吗?
$this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'condensed',
'id' => 'provider-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'name',
'email',
array('name' => 'created_at', 'filter' => false), // solved by this
array('name' => 'updated_at', 'filter' => false), // solved by this
array(
'class' => 'bootstrap.widgets.TbButtonColumn',
'htmlOptions' => array(
//'nowrap' => 'nowrap'
),
'template' => '{login} {view} {update} {delete}', // https://github.com/yiisoft/yii/blob/1.1.13/framework/zii/widgets/grid/CButtonColumn.php#L46
'buttons' => array(
'login' => array(
'label' => Yii::t('bus', 'Login to Administrator Site'),
'options' => array(
'title' => Yii::t('bus', 'Login to Administrator Site'),
'target' => '_blank'
),
'url' => 'Yii::app()->createUrl(
"/administrator/default/index",
array(
"provider_id" => $data->id
)
)',
'icon' => 'share'
),
)
),
),
));
答案 0 :(得分:2)
查看CDataColumn::filter
的文档。您可以将此属性设置为false
以禁用列过滤器。
'columns' => array(
// ...
array(
'name' => 'age'
'filter' => false,
),