2
是否有可能在一個admin.php中有2個不同的CGridView表?在Yii的一個admin.php中可以有2個不同的CGridView嗎?
例如,我有一個服務頁面和一個包頁面。
服務基本上是單獨的單一服務,而包由單個服務組成。
所以,我的問題是,我可以將服務的CGridView顯示在Package/admin.php頁面中嗎?一個獨立的CGridView表格。
帶有軟件包列表的頂部部分,底部是帶有單獨服務的不同表格。
如果是這樣,請引導我通過它。提前致謝。
更新
public function actionAdmin() {
$model = new Package('search');
$model2 = new Service('search');
$model->unsetAttributes();
$model2->unsetAttributes();
$model->active=1;
$model2->active=1;
if (isset($_GET['Package'])){
$model->setAttributes($_GET['Package']);
}
$this->render('admin', array(
'model' => $model,
'model2' => $model2,
));
}
在_form.php這個:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id' => 'service-grid',
'dataProvider' => $model2->search(),
'htmlOptions'=>array('class'=>'grid-view grid-size'),
'filter' => $model2,
'columns' => array(//the appropriate columns
));
對不起,我不太明白。但是,你所做的不是來自同一張桌子,而是分開的桌子?我想要2個不同的表在同一個頁面中分開的表中。如果我錯了,請糾正我。 – NewbieCoder
謝謝!你救了我的一天!乾杯;) – NewbieCoder
好吧,現在我已經成功地將2個表整合到1個管理頁面中。但是對於搜索,它不適用於第二張桌子。原表中的搜索非常好,但不在第二張表中。我可以知道我可以添加什麼,以便它正常工作嗎?謝謝 – NewbieCoder