This commit is contained in:
Билай Станислав 2024-08-12 15:39:26 +03:00
parent 38d5deb36a
commit 19e994ef38
4 changed files with 10 additions and 5 deletions

View File

@ -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},

View File

@ -15,6 +15,7 @@ $table->columns([
'description' => [
"format" => "html",
"style" => ["width" => "300px"],
"filter" => '',
"value" => function ($cell) {
return "<span style='color: sienna'>$cell</span>";
}

View File

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

View File

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