From 8bc08393050e4376346ce013682f994261f73593 Mon Sep 17 00:00:00 2001 From: blobt <380255922@qq.com> Date: Thu, 8 Aug 2019 17:46:40 +0800 Subject: [PATCH] =?UTF-8?q?grid=20view=20=E6=B7=BB=E5=8A=A0=E9=A1=B5?= =?UTF-8?q?=E6=95=B0=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/models/CategorySearch.php | 26 +++++++++++++--------- kcadmin/assets/AppAsset.php | 1 - kcadmin/views/category/create.php | 2 +- kcadmin/views/category/index.php | 3 +++ kcadmin/web/css/site.css | 37 ------------------------------- 5 files changed, 20 insertions(+), 49 deletions(-) diff --git a/common/models/CategorySearch.php b/common/models/CategorySearch.php index 4b2e392..c22a1d6 100644 --- a/common/models/CategorySearch.php +++ b/common/models/CategorySearch.php @@ -9,13 +9,12 @@ use common\models\Category; /** * CategorySearch represents the model behind the search form of `\common\models\Category`. */ -class CategorySearch extends Category -{ +class CategorySearch extends Category { + /** * {@inheritdoc} */ - public function rules() - { + public function rules() { return [ [['id', 'icon_type', 'sort_order', 'created_at', 'updated_at'], 'integer'], [['cat_name', 'icon', 'description'], 'safe'], @@ -25,8 +24,7 @@ class CategorySearch extends Category /** * {@inheritdoc} */ - public function scenarios() - { + public function scenarios() { // bypass scenarios() implementation in the parent class return Model::scenarios(); } @@ -38,14 +36,21 @@ class CategorySearch extends Category * * @return ActiveDataProvider */ - public function search($params) - { + public function search($params) { $query = Category::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, + 'pagination' => [ + 'pageSizeLimit' => [1, 200] + ], + 'sort' => [ + 'defaultOrder' => [ + 'id' => SORT_DESC, + ] + ], ]); $this->load($params); @@ -66,9 +71,10 @@ class CategorySearch extends Category ]); $query->andFilterWhere(['like', 'cat_name', $this->cat_name]) - ->andFilterWhere(['like', 'icon', $this->icon]) - ->andFilterWhere(['like', 'description', $this->description]); + ->andFilterWhere(['like', 'icon', $this->icon]) + ->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; } + } diff --git a/kcadmin/assets/AppAsset.php b/kcadmin/assets/AppAsset.php index 7c22300..43351e5 100644 --- a/kcadmin/assets/AppAsset.php +++ b/kcadmin/assets/AppAsset.php @@ -21,6 +21,5 @@ class AppAsset extends AssetBundle 'yii\bootstrap\BootstrapAsset', 'yii\bootstrap\BootstrapPluginAsset', 'blobt\web\AdminlteAsset', - 'blobt\web\DatatableBootstrap' ]; } diff --git a/kcadmin/views/category/create.php b/kcadmin/views/category/create.php index a727e42..48abbb7 100644 --- a/kcadmin/views/category/create.php +++ b/kcadmin/views/category/create.php @@ -14,7 +14,7 @@ $this->params['breadcrumbs'][] = $this->title;

title) ?>

render('_form', [ - 'model' => $model, + 'model' => $model, ]) ?> diff --git a/kcadmin/views/category/index.php b/kcadmin/views/category/index.php index 212d070..bbb6b41 100644 --- a/kcadmin/views/category/index.php +++ b/kcadmin/views/category/index.php @@ -3,6 +3,7 @@ use yii\helpers\Html; use blobt\grid\GridView; +//use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel common\models\CategorySearch */ @@ -11,11 +12,13 @@ use blobt\grid\GridView; $this->title = 'Categories'; $this->params['breadcrumbs'][] = $this->title; ?> +
$dataProvider, + 'filterSelector' => 'select[name="per-page"]', 'columns' => [ 'id', 'cat_name', diff --git a/kcadmin/web/css/site.css b/kcadmin/web/css/site.css index b6e133e..83a29a0 100644 --- a/kcadmin/web/css/site.css +++ b/kcadmin/web/css/site.css @@ -30,41 +30,4 @@ .login-form h6 { text-align: center; -} - - -/*datatable修改*/ -table.dataTable thead > tr > th.sorting_asc, table.dataTable thead > tr > th.sorting_desc, table.dataTable thead > tr > th.sorting, -table.dataTable thead > tr > td.sorting_asc, -table.dataTable thead > tr > td.sorting_desc, -table.dataTable thead > tr > td.sorting { - padding-right: 8px; -} - -table.dataTable thead > tr > th > a{ - position: relative; - display: block; - color:#333333; - font-family: 'Glyphicons Halflings'; -} - -table.dataTable thead > tr > th > a:after{ - position: absolute; - right: 0px; - opacity: 0.2; - content: "\e150"; -} - -table.dataTable thead > tr > th > a.asc:after{ - position: absolute; - right: 0px; - content: "\e155"; - opacity: 0.6; -} - -table.dataTable thead > tr > th > a.desc:after{ - position: absolute; - right: 0px; - content: "\e156"; - opacity: 0.6; } \ No newline at end of file