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; }