From 2d2c69f3d029827147f97595d377c9dc82b73790 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Thu, 17 Jan 2019 22:31:05 +0200 Subject: [PATCH 1/5] Don't apply sorting in case sortable=false. jsPaginator also exclusively calls applySort(), so applySort() should take care of that itself. --- src/Grid.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Grid.php b/src/Grid.php index 723195d8b5..2601788422 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -428,6 +428,10 @@ public function getSortBy() */ public function applySort() { + if ($this->sortable === false) { + return; + } + $sortBy = $this->getSortBy(); if ($sortBy && $this->paginator) { @@ -535,12 +539,7 @@ private function setModelLimitFromPaginator() public function renderView() { // take care of sorting - if ($this->sortable === null) { - $this->sortable = true; - } - if ($this->sortable) { - $this->applySort(); - } + $this->applySort(); return parent::renderView(); } From 04e1d4b0653977d37b8b18e832c2a2b29cc5b4c4 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Thu, 17 Jan 2019 22:54:17 +0200 Subject: [PATCH 2/5] addAction and addModalAction buttons in demo --- demos/scroll-grid-container.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/demos/scroll-grid-container.php b/demos/scroll-grid-container.php index 4106ff1bc8..b056820633 100644 --- a/demos/scroll-grid-container.php +++ b/demos/scroll-grid-container.php @@ -17,6 +17,14 @@ $g1->addQuickSearch(['name', 'iso']); $g1->addJsPaginatorInContainer(30, 350); +// demo for additional action buttons in CRUD + jsPaginator +$g1->addModalAction(['icon'=>'cogs'], 'Details', function ($p, $id) use ($g1) { + $p->add(['Card'])->setModel($g1->model->load($id)); +}); +$g1->addAction('red', function($js){ + return $js->closest('tr')->css('color', 'red'); +}); + $c2 = $c->addColumn(); $g2 = $c2->add(['Grid', 'menu' => false]); $m2 = $g2->setModel(new Country($db)); From 9cb2eeff692653ae8e6345559bc5d23c27441699 Mon Sep 17 00:00:00 2001 From: Romans Malinovskis Date: Thu, 17 Jan 2019 20:54:30 +0000 Subject: [PATCH 3/5] Apply fixes from StyleCI --- demos/scroll-grid-container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/scroll-grid-container.php b/demos/scroll-grid-container.php index b056820633..2fb77e6ad7 100644 --- a/demos/scroll-grid-container.php +++ b/demos/scroll-grid-container.php @@ -21,7 +21,7 @@ $g1->addModalAction(['icon'=>'cogs'], 'Details', function ($p, $id) use ($g1) { $p->add(['Card'])->setModel($g1->model->load($id)); }); -$g1->addAction('red', function($js){ +$g1->addAction('red', function ($js) { return $js->closest('tr')->css('color', 'red'); }); From e31c91a64271c5908095d52222dd32dcbd667697 Mon Sep 17 00:00:00 2001 From: DarkSide Date: Thu, 17 Jan 2019 23:02:37 +0200 Subject: [PATCH 4/5] fix demo --- demos/scroll-grid-container.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demos/scroll-grid-container.php b/demos/scroll-grid-container.php index 2fb77e6ad7..15c84b9811 100644 --- a/demos/scroll-grid-container.php +++ b/demos/scroll-grid-container.php @@ -13,9 +13,8 @@ $c1 = $c->addColumn(); $g1 = $c1->add(['CRUD']); -$m1 = $g1->setModel(new Country($db), ['name', 'iso']); +$m1 = $g1->setModel(new Country($db));//, ['name', 'iso']); $g1->addQuickSearch(['name', 'iso']); -$g1->addJsPaginatorInContainer(30, 350); // demo for additional action buttons in CRUD + jsPaginator $g1->addModalAction(['icon'=>'cogs'], 'Details', function ($p, $id) use ($g1) { @@ -24,6 +23,8 @@ $g1->addAction('red', function ($js) { return $js->closest('tr')->css('color', 'red'); }); +// THIS SHOULD GO AFTER YOU CALL addAction() !!! +$g1->addJsPaginatorInContainer(30, 350); $c2 = $c->addColumn(); $g2 = $c2->add(['Grid', 'menu' => false]); From 64d04b17d12cc271191863967f15a030fb552a88 Mon Sep 17 00:00:00 2001 From: Romans Malinovskis Date: Thu, 17 Jan 2019 21:03:06 +0000 Subject: [PATCH 5/5] Apply fixes from StyleCI --- demos/scroll-grid-container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/scroll-grid-container.php b/demos/scroll-grid-container.php index 15c84b9811..3b6abeb5d5 100644 --- a/demos/scroll-grid-container.php +++ b/demos/scroll-grid-container.php @@ -13,7 +13,7 @@ $c1 = $c->addColumn(); $g1 = $c1->add(['CRUD']); -$m1 = $g1->setModel(new Country($db));//, ['name', 'iso']); +$m1 = $g1->setModel(new Country($db)); //, ['name', 'iso']); $g1->addQuickSearch(['name', 'iso']); // demo for additional action buttons in CRUD + jsPaginator