From 19e994ef38e10d4dcaec97e7b986d1cc5e8471b8 Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Mon, 12 Aug 2024 15:39:26 +0300 Subject: [PATCH] filetrs --- examples/simple.json | 2 +- examples/simple.php | 1 + src/JasonTable.php | 2 +- src/ListJsonTable.php | 10 +++++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/simple.json b/examples/simple.json index f883fe4..5c7a148 100644 --- a/examples/simple.json +++ b/examples/simple.json @@ -20,7 +20,7 @@ "params": {"class": "table table-bordered", "border": "1"} }, "filters": [ - "email", "description" + "email" ], "data": [ {"id": 1,"email":"fas1@mail.ru","description":"sdgsdfg","description2":"ffdghdas", "created_at": "17.06.2024", "status": 1}, diff --git a/examples/simple.php b/examples/simple.php index 7353dba..b96b64d 100644 --- a/examples/simple.php +++ b/examples/simple.php @@ -15,6 +15,7 @@ $table->columns([ 'description' => [ "format" => "html", "style" => ["width" => "300px"], + "filter" => '', "value" => function ($cell) { return "$cell"; } diff --git a/src/JasonTable.php b/src/JasonTable.php index 4764cd2..5080b1d 100644 --- a/src/JasonTable.php +++ b/src/JasonTable.php @@ -4,7 +4,7 @@ namespace Itguild\Tables; class JasonTable { - protected string $html = ""; + public string $html = ""; protected \Closure|array|false $beforePrintCell; protected \Closure|false $afterPrintHook; protected \Closure|false $beforePrintHook; diff --git a/src/ListJsonTable.php b/src/ListJsonTable.php index 759b27e..051de24 100644 --- a/src/ListJsonTable.php +++ b/src/ListJsonTable.php @@ -201,10 +201,10 @@ class ListJsonTable extends JasonTable return false; } - private function issetFilter($filter): bool + private function issetFilter(string $filter): bool { if (isset($this->data['filters'])) { - foreach ($this->data['filters'] as $key => $currentFilter) { + foreach ($this->data['filters'] as $currentFilter) { if (is_array($currentFilter)) { return false; } elseif (is_string($currentFilter)) { @@ -214,7 +214,11 @@ class ListJsonTable extends JasonTable } } } - + if (is_array($this->beforePrintCell[$filter])) { + if (isset($this->beforePrintCell[$filter]['filter'])) { + return true; + } + } return false; }