2

我有两个数据提供者,就像这样。

         $marks=new Assignmentmarks;
         $student=new student;
        $criteria_st=new CDbCriteria;
        $criteria_marks=new CDbCriteria;
        $criteria_st->compare('st_id', $student->st_id);
        $criteria_st->addInCondition('st_id', $studentid);
        $criteria_st->compare('st_name', $student->st_name);


        $criteria_marks->compare('marks_cr1', $marks->marks_cr1,TRUE);
        $criteria_marks->compare('marks_cr2', $marks->marks_cr2,TRUE);  
        $criteria_marks->compare('marks_cr3', $marks->marks_cr3,TRUE);
        $criteria_marks->compare('marks_cr4', $marks->marks_cr4,TRUE); 
        $criteria_marks->compare('marks_cr5', $marks->marks_cr5,TRUE);

        $DataProvider1= new  CActiveDataProvider($student, array('criteria_st'=>$criteria_st,));
        $DataProvider2= new  CActiveDataProvider($marks, array('criteria_marks'=>$criteria_marks,));

我需要将这两个数据提供者放到 CGridView 中。

任何人都可以告诉我如何做到这一点,或者如果有其他方法可以做到这一点,我也喜欢知道吗?

4

1 回答 1

0
 public function actionIndex()
        {
            // renders the view file 'protected/views/site/index.php'
            // using the default layout 'protected/views/layouts/main.php'

                $dataProviderHotel=new CActiveDataProvider('Hotel',array(
                    'criteria'=>array(
                        'condition'=>'hotel_rating > 8',
                        ),
                        'pagination'=>array(
                            'pageSize'=>20,
                        ),
                    ));

                $dataProviderItems = new CActiveDataProvider('Item',array(
                    'criteria'=>array(
                        'condition'=>'hotel_rating > 8',
                        ),
                        'pagination'=>array(
                            'pageSize'=>20,
                        ),
                    ));
    $this->render('index',array(
            'dataProvider1'=>$dataProviderHotel,
            'dataProvider2'=>$dataProviderItem
        ));
}


 <?php $this->widget('zii.widgets.CListView', array(
        'dataProvider'=>$dataProvider1,
        'summaryText'=>'',
        'itemView'=>'_topHotels',  ));   ?>
于 2016-08-23T07:50:42.233 回答