我正在使用tabx小部件,并希望在其中显示gridview。怎么做?
tabsx位于前端,gridview(CRUD)来自后端..那么是否可以在前端显示gridview?
这里是代码index.php
echo TabsX::widget([
'position' => TabsX::POS_ABOVE,
'align' => TabsX::ALIGN_LEFT,
'items' => [
[
'label' => 'gridview',
'content' => $content_grid,//**want gridview index page to open here... how to do it.. views\companies\index.php**
'active' => true
],
[
'label' => 'Basic Search',
'content' => $content_basic_search,
'headerOptions' => ['style'=>'font-weight:bold'],
'options' => ['id' => 'myveryownID'],
],
[
'label' => 'Dropdown',
'items' => [
[
'label' => 'DropdownA',
'content' => 'DropdownA, Anim pariatur cliche...',
],
[
'label' => 'DropdownB',
'content' => 'DropdownB, Anim pariatur cliche...',
],
],
],
],
]);
如何在tabsx中获取gridview ??
答案 0 :(得分:0)
您可以使用此
'label' => 'gridview',
'content' => $yourModel->getGridView(),
'active' => true
然后在$ yourModel:
中定义getGridView函数public function getGridView($id)
{
$searchModel = new YourModelSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('_view_index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
或 直接在视图上渲染网格:
'label' => 'gridview',
'content' => $this->render('_grid' , ['dataProvider'=>$dataProvider,'searchModel' => $searchModel]),
'active' => true