我正在使用Gridview,我以表格形式显示来自数据库的记录,形成一个保存记录的记录。分页也已启用,以便我可以跳转到任何页面。
现在,我必须在Cgridview中添加一个单独的div,以便我可以在表格中添加样式。
怎么做?
$this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'bordered striped',
'id' => 'cars_search_grid',
'dataProvider' => $model->search_cars(),
'ajaxUpdate' => true,
'filter' => null,
'columns' => $selected_columns,
'enablePagination' => true
));
生成的输出结构如下所示--->
<div id="cars_search_grid" class="grid-view">
<table class="items table table-bordered table-striped">
<div class="row-fluid">
<div>'This DIV holds the {Pager}'</div>
<div>'This DIV holds the {Summary}'<div>
</div>
</div>
我的目标是输出类似的东西---&gt;
<div id="cars_search_grid" class="grid-view">
<div> //This is where i want to put a DIV
<table class="items table table-bordered table-striped">
</div>
<div class="row-fluid">
<div>'This DIV holds the {Pager}'</div>
<div>'This DIV holds the {Summary}'<div>
</div>
</div>
答案 0 :(得分:1)
以下更改让我实现目标
添加了&#39;模板&#39;到Gridview,它工作
$this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'bordered striped',
'id' => 'cars_search_grid',
'dataProvider' => $model->search_cars(),
'ajaxUpdate' => true,
'filter' => null,
'template'=>'<div style="overflow:auto;">{items}</div>{pager}{summary}',
'columns' => $selected_columns,
'enablePagination' => true
));
答案 1 :(得分:0)
要为表格设置样式,只需使用CSS选择器
即可.grid-view table.items {
或更具体地说,仅限于此网格视图,
#cars_search_grid table.items {
答案 2 :(得分:0)