add custom columns filter
This commit is contained in:
parent
af1b996766
commit
77a306a0f6
@ -9,12 +9,13 @@ $table = new ListJsonTable($json);
|
||||
|
||||
$table->columns([
|
||||
"created_at" => [
|
||||
"format" => "date:Y-m-d"
|
||||
"format" => "date:Y-m-d",
|
||||
'filter' => "date"
|
||||
],
|
||||
'description' => [
|
||||
"format" => "html",
|
||||
"style" => ["width" => "300px"],
|
||||
"filter" => '',
|
||||
"filter" => "text",
|
||||
"value" => function ($cell) {
|
||||
return "<span style='color: sienna'>$cell</span>";
|
||||
}
|
||||
|
@ -90,4 +90,14 @@ class JasonTable
|
||||
|
||||
return $styleStr;
|
||||
}
|
||||
|
||||
protected function getFilterFromCustomColumn(string $column)
|
||||
{
|
||||
if (is_array($this->beforePrintCell[$column])) {
|
||||
if (isset($this->beforePrintCell[$column]['filter'])) {
|
||||
return $this->beforePrintCell[$column]['filter'];
|
||||
}
|
||||
}
|
||||
return "text";
|
||||
}
|
||||
}
|
@ -251,7 +251,7 @@ class ListJsonTable extends JasonTable
|
||||
$this->html .= "<tr><form action='$this->baseUrl/search'>";
|
||||
foreach ($columnKeys as $key){
|
||||
if ($this->issetFilter($key)){
|
||||
$this->html .= "<td><input type='text' name='$key'></td>";
|
||||
$this->html .= "<td><input type='" . $this->getFilterFromCustomColumn($key) . "' name='$key'></td>";
|
||||
}
|
||||
else {
|
||||
$this->html .= "<td></td>";
|
||||
|
Loading…
Reference in New Issue
Block a user