Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit52b7370

Browse files
authored
[4.0] Add support for search panes extension. (yajra#137)
* WIP: Add support for search panes extension.Fixyajra/laravel-datatables#2463* Add threshold and viewTotal setter.* Support search panes on column builder.* Add more search pane options.* Add search pane name.* Orthogonal option setter.* Add Column Definition classes.* Allow callback value for searchPane.* Add hideTotal api.
1 parentfefbf5b commit52b7370

File tree

7 files changed

+422
-3
lines changed

7 files changed

+422
-3
lines changed

‎src/Html/Column.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
useIlluminate\Support\Arr;
66
useIlluminate\Support\Str;
77
useIlluminate\Support\Fluent;
8+
useYajra\DataTables\Html\Options\Plugins\SearchPanes;
89

910
/**
1011
* @property string data
@@ -19,6 +20,8 @@
1920
*/
2021
class Columnextends Fluent
2122
{
23+
use SearchPanes;
24+
2225
/**
2326
* @param array $attributes
2427
*/
@@ -101,7 +104,7 @@ public function orderable(bool $flag = true)
101104

102105
return$this;
103106
}
104-
107+
105108
/**
106109
* Set column responsive priority.
107110
*

‎src/Html/ColumnDefinition.php‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespaceYajra\DataTables\Html;
4+
5+
useIlluminate\Support\Fluent;
6+
7+
class ColumnDefinitionextends Fluent
8+
{
9+
use HasOptions;
10+
11+
publicfunctiontargets($value)
12+
{
13+
$this->attributes['targets'] = (array)$value;
14+
15+
return$this;
16+
}
17+
}

‎src/Html/ColumnDefinitions.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespaceYajra\DataTables\Html;
4+
5+
useIlluminate\Support\Collection;
6+
7+
class ColumnDefinitionsextends Collection
8+
{
9+
10+
}

‎src/Html/HasOptions.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ trait HasOptions
2727
useOptions\Plugins\RowReorder;
2828
useOptions\Plugins\Scroller;
2929
useOptions\Plugins\Select;
30+
useOptions\Plugins\SearchPanes;
3031

3132
/**
3233
* Set deferLoading option value.

‎src/Html/Options/HasColumns.php‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
useIlluminate\Support\Collection;
66
useIlluminate\Support\Str;
77
useYajra\DataTables\Html\Column;
8+
useIlluminate\Contracts\Support\Arrayable;
89

910
/**
1011
* DataTables - Columns option builder.
@@ -16,17 +17,47 @@ trait HasColumns
1617
/**
1718
* Set columnDefs option value.
1819
*
19-
* @paramarray $value
20+
* @parammixed $value
2021
* @return $this
2122
* @see https://datatables.net/reference/option/columnDefs
2223
*/
23-
publicfunctioncolumnDefs(array$value)
24+
publicfunctioncolumnDefs($value)
2425
{
26+
if (is_callable($value)) {
27+
$value =app()->call($value);
28+
}
29+
30+
if ($valueinstanceof Arrayable) {
31+
$value =$value->toArray();
32+
}
33+
2534
$this->attributes['columnDefs'] =$value;
2635

2736
return$this;
2837
}
2938

39+
/**
40+
* Add a columnDef option.
41+
*
42+
* @param mixed $value
43+
* @return $this
44+
* @see https://datatables.net/reference/option/columnDefs
45+
*/
46+
publicfunctionaddColumnDef($value)
47+
{
48+
if (is_callable($value)) {
49+
$value =app()->call($value);
50+
}
51+
52+
if ($valueinstanceof Arrayable) {
53+
$value =$value->toArray();
54+
}
55+
56+
$this->attributes['columnDefs'][] =$value;
57+
58+
return$this;
59+
}
60+
3061
/**
3162
* Set columns option value.
3263
*
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespaceYajra\DataTables\Html\Options\Plugins;
4+
5+
useYajra\DataTables\Html\SearchPane;
6+
useIlluminate\Contracts\Support\Arrayable;
7+
8+
/**
9+
* DataTables - Search panes plugin option builder.
10+
*
11+
* @see https://datatables.net/extensions/searchpanes
12+
* @see https://datatables.net/reference/option/searchPanes
13+
*/
14+
trait SearchPanes
15+
{
16+
/**
17+
* Set searchPane option value.
18+
*
19+
* @param bool|array $value
20+
* @return $this
21+
* @see https://datatables.net/reference/option/searchPanes
22+
*/
23+
publicfunctionsearchPanes($value =true)
24+
{
25+
if (is_callable($value)) {
26+
$value =app()->call($value);
27+
}
28+
29+
if ($valueinstanceof Arrayable) {
30+
$value =$value->toArray();
31+
}
32+
33+
if (is_bool($value)) {
34+
$value = SearchPane::make()->show($value)->toArray();
35+
}
36+
37+
$this->attributes['searchPanes'] =$value;
38+
39+
return$this;
40+
}
41+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp