2014-02-21 72 views
2

我使用Yiibootstrap功能;Yii自定義CGridView項目模板

所以,我從divtable改變容器tagName;

現在,帶有items類的表在table類的表內;

template屬性定義了我的問題;

如何添加以下類:table table-striped table-hoveritems類的表中?

表結構爲:

<table class="table"> 
<tr> 
<td> 
<table class="items"> 
... 

{items}產生<table class="items">

<?php 
      $this->widget('zii.widgets.grid.CGridView', array(
       'id' => 'orders-grid', 
       'dataProvider' => $model->search(), 
       'filter' => $model, 
       'ajaxUrl' => Yii::app()->baseUrl . '/orders/admin', 
       'tagName' => 'table', 
       'htmlOptions' => array(
        'class' => 'table', 
        'style' => 'width:auto;', 
        'align' => 'left', 
       ), 
       'cssFile' => Yii::app()->baseUrl . '/css/custom.css', 
       'template' => 
       '<tr><td style="border-top:none;height:74px;">{pager}</td></tr>' . 
       '<tr><td style="height:34px;border-top:none;">{summary}</td></tr>' . 
       '<tr><td>{items}</td></tr>' . 
       '<tr><td style="border-top:none;">{summary}</td></tr>' . 
       '<tr><td style="border-top:none;height:74px;">{pager}</td></tr>', 
       'columns' => array(
        array(
         'header' => 'Order ID', 
         'name' => 'id', 
         'type' => 'raw', 
         'value' => 'CHtml::link(str_pad($data->id, 9, "0", STR_PAD_LEFT),array("update","id"=>$data->id))', 
        ), 
        array(
         'header' => 'Name', 
         'name' => 'var_user_full_name', 
         'value' => '$data->UserFullName', 
         'filter' => CHtml::activeTextField($model, 'var_user_full_name'), 
        ), 
        array(
         'name' => 'total_price', 
         'type' => 'raw', 
         'value' => 'CurrencyData::$_currency[$data->currency]." ".$data->total_price', 
        ), 
        array(
         'name' => 'created', 
         'value' => 'date("d/m/Y",$data->created)', 
         'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array(
          'model' => $model, 
          'attribute' => 'created', 
          'language' => 'en-AU', 
//       'i18nScriptFile' => 'jquery.ui.datepicker-en.js', 
          'htmlOptions' => array(
           'id' => 'datepicker_for_due_date', 
           'size' => '10', 
          ), 
          'defaultOptions' => array(
           'showOn' => 'focus', 
           'dateFormat' => 'dd/mm/yy', 
           'showOtherMonths' => true, 
           'selectOtherMonths' => true, 
           'changeMonth' => true, 
           'changeYear' => true, 
           'showButtonPanel' => true, 
          ) 
           ), true), 
        ), 
        array(
         'name' => 'active', 
         'header' => 'Status', 
         'value' => 'OrdersData::$active[$data->active]', 
         //'filter' => OrdersData::$active, 
         'filter' => CHtml::activeDropDownList($model, 'active', OrdersData::$active, array('prompt' => '-Select-')), 
        ), 
        array(
         'class' => 'CButtonColumn', 
         'header' => 'Action', 
         'template' => '{update}', 
        ), 
       ), 
      )); 
      ?> 

回答

2

發現:

'itemsCssClass' => 'table table-striped table-hover', 
+0

正是我一直在尋找 – iGbanam