lundi 7 août 2017

How to Add Filter Search Like Grid View In List View Yii2

I Want to Add Filter With List View (Some Thing Like What Is In Grid View). But I Don Not Know How Do That :( Filters I Want Are CheckBox And DropDown Options.

Here Is My Action Code In SiteController

<?php

public function actionMobiles(){
   $searchModel = new MobileSearch();
    //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
 //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);

    $dataProvider = new ActiveDataProvider([
    'query' => Mobile::find(),
    'pagination' => [
    'pageSize' => 1,
],
]);

// get the posts in the current page
//$posts = $dataProvider->getModels();
return $this->render('mobiles', ['dataProvider' => $dataProvider,'searchModel' => $searchModel]);


}

?>

In View File I Have 2 Files :

Here Is mobiles View :

 <?php
 use yii\widgets\ListView;
 use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\ArrayHelper ;
use app\models\Mobile;
 ?>

 <?= ListView::widget([
    'dataProvider' => $dataProvider,
           //'filterModel' => $searchModel,
      'itemView' => '_mobiles',

]); ?>

And In _mobiles I Have :

<?php
use yii\widgets\DetailView;
?>

<?= DetailView::widget([
    'model' => $model,
    'attributes' => [
        //'id',
        'id',
        'title',
        //'ativo',
    ],
]) ?>

It Shows Data From DataBase Correctly With It Pagination. But How To Add Filter To Update List(CheckBox And DropDown List Are Use to Update)??

Thanks ;)

Aucun commentaire:

Enregistrer un commentaire