TbPager Yii Yiibooster

时间:2014-03-13 10:05:08

标签: gridview yii pager

我正在使用Yiibooster,ExtendedGridView和TbPager。过滤后,结果不会显示在页面上。例如,我总计有5个结果,前2个结果在第1页,其他3个在网格的第2页。

由于

编辑:

型号:

 public function search() {
    $criteria = new CDbCriteria;
    $criteria->together = true;
    $criteria->with = array('training','instructor','room','contactdetails','status');

    $criteria->compare('id', $this->id);
    $criteria->compare('trainingid', $this->trainingid);
    $criteria->compare('categoryid',$this->categoryid);
    $criteria->compare('roomid', $this->roomid);
    $criteria->compare('instructorid', $this->instructorid);
    $criteria->compare('statusid', $this->statusid);
    $criteria->compare('termin', $this->termin);
    $criteria->compare('duration', $this->duration);
    $criteria->compare('maxparticipants', $this->maxparticipants);
    $criteria->compare('comment', $this->comment);
    $criteria->compare('contactdetailid', $this->instructorid);

    if (!empty($this->from_date) && empty($this->to_date)) {
       $criteria->condition = "termin >= '$this->from_date'"; 
    } elseif (!empty($this->to_date) && empty($this->from_date)) {
       $criteria->condition = "termin <= '$this->to_date'";
    } elseif (!empty($this->to_date) && !empty($this->from_date)) {         
       $criteria->condition = "termin  >= '$this->from_date' and              termin<='$this->to_date'";        
    }


    return new CActiveDataProvider($this, array(
        'criteria' => $criteria,
        'sort'=>array(
        'defaultOrder'=>array(
                     'termin ASC',
                    )
    ),
        'pagination' => array(
            'pageSize' => 15),

    ));

}

查看:

  $this->widget('bootstrap.widgets.TbExtendedGridView', array(
        'type' => 'striped bordered',
        'dataProvider' => $model->search(),
        'afterAjaxUpdate' => 'reinstallDatePicker',
        'enablePagination'=>true,
        'summaryText'=>'{count} Ergebnisse',
        'template' => "{summary}{items}\n{pager}",
        'filter' => $model,
        'pager' => array(
                'class' => 'bootstrap.widgets.TbPager'),
        'columns' =>  array(  
                array(
                  'type' => 'raw',
                  'value' => 'Seminar::getStatusIcon($data->id)',
                  'header' => 'Status',
                  'htmlOptions' => array('width' => '20px')),
               array(
                  'type' => 'raw',
                  'value' => 'Seminar::getMyBookingStatus($data->id)',
                  'header' => 'Mein Status',
                  'htmlOptions' => array('width' => '120px'),
                  'filter' => CHtml::listData(Bookingstatus::model()->findAll(), 'id', 'name')),
               array(
                  'name' => 'trainingid',
                  'value' => '$data->training->name',
                  'header' => 'Kurs',
                  'filter' => CHtml::listData($model->findAll(array('order' => 'trainingid ASC')), 'trainingid', 'training.name')),
              array(
                  'name' => 'categoryid',
                  'value' => '$data->training->category->name',
                  'header' => 'Kategorie',
                  'filter' => CHtml::listData(Tcategory::model()->findAll(array('order' => 'name ASC')), 'id', 'name')),       
             array(
                 'name' => 'termin',
                 'header' => 'Termin',
                 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                 'model' => $model,
                 'attribute' => 'termin',
                 'language' => 'de',
                 'i18nScriptFile' => 'jquery.ui.datepicker-ja.js',
                 'htmlOptions' => array(
                 'id' => 'Projects_confirmStart',
                 'dateFormat' => 'yy-mm-dd',),

                 'options' => array(
                              'showOn' => 'focus',
                              'showOtherMonths' => true,
                              'selectOtherMonths' => true,
                              'changeMonth' => true,
                              'changeYear' => true,
                              'showButtonPanel' => true,
                                   )
                              ), true),
    ), ........

控制器:

       public function actionIndex() {

               $this->layout = '//layouts/column1';

               unset(Yii::app()->request->cookies['from_date']);  
               unset(Yii::app()->request->cookies['to_date']);

               $model = new Seminar('search');

               $model->unsetAttributes();  


               if(!empty($_POST))
                    {      
                     Yii::app()->request->cookies['from_date'] = new CHttpCookie('from_date', $_POST['from_date']);  // define cookie for from_date
                     Yii::app()->request->cookies['to_date'] = new CHttpCookie('to_date', $_POST['to_date']);
                     $model->from_date = $_POST['from_date'];
                     $model->to_date = $_POST['to_date'];
                    }

                if(isset($_GET['Seminar'])){

                     $model->attributes=$_GET['Seminar'];

                   }


                $this->render('index', array(
                      'model' => $model,        
                 ));
                  }

0 个答案:

没有答案