Two GridViews in one view

2019-02-27 08:35发布

I developed a web site with Yii2 framework and I need some help. I need to show two different GridViews with different data in one of my pages. I managed to show the tables and their data, but when I switch from the page of one table to another, the pages the other tables change too.

How can I work on one table without get the others one involved? (I'm using yii2-grid from Kartik-v)

<?= GridView::widget([
  'dataProvider' => $dataProvider1,
  'filterModel'  => $searchModel1,
  'columns'      => $this->context->columnDefaultList($parm1),
]); ?>

<hr class="page_separator"/>

<?= GridView::widget([
 'dataProvider' => $dataProvider2,
 'filterModel'  => $searchModel2,
 'columns'      => $this->context->columnDefaultList($Parm2),
]); ?>

标签: yii2
1条回答
ゆ 、 Hurt°
2楼-- · 2019-02-27 09:00

Configure You Dataprovider as

 $dataprovider1->pagination->pageParam = 'dp1';
 $dataprovider1->pagination->pageSizeParam = 'dp1-size';

 $dataprovider2->pagination->pageParam = 'dp2';
 $dataprovider2->pagination->pageSizeParam = 'dp2-size';
查看更多
登录 后发表回答