2017-11-07 11 views
1

tabx 위젯을 사용하고 있는데 gridview를 표시하려고합니다. 그렇게하는 방법 ?yii2의 tabsx에서 gridview를 표시하는 방법

tabsx는 frontend에 있고 gridview (CRUD)는 백엔드에서입니다. 그러면 frontend에 gridview를 표시 할 수 있습니까? 여기

코드의 index.php

방법 tabsx에있는 gridview를 얻는
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...', 
       ], 
      ], 
     ], 
    ], 
]); 

입니까 ??

답변

0

 'label' => 'gridview', 
     'content' => $yourModel->getGridView(), 
     'active' => true 

그런 다음 $ yourModel에 getGridView의 funciton를 정의 할 수 있습니다 :

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 
+0

이 tabsx입니다 yii2 고급 애플 리케이션의 프론트 엔드 및 gridview는 백엔드에 .. 어떻게 그 파일을 렌더링 백엔드 /보기/기업/색인 .php – Goli