|
12 | 12 | trait RowGroup |
13 | 13 | { |
14 | 14 | /** |
15 | | - * Set rowGroup option value. |
| 15 | + * Set rowGroup className option value. |
16 | 16 | * |
17 | | - * @param bool|array $value |
| 17 | + * @param string $value |
18 | 18 | * @return $this |
19 | | - * @see https://datatables.net/reference/option/rowGroup |
| 19 | + * @see https://datatables.net/reference/option/rowGroup.className |
20 | 20 | */ |
21 | | - public function rowGroup(bool|array $value = true): static |
| 21 | + public function rowGroupUpdate(string $value = 'group'): static |
22 | 22 | { |
23 | | - $this->attributes['rowGroup'] = $value; |
24 | | - |
25 | | - return $this; |
| 23 | + return $this->rowGroup(['className' => $value]); |
26 | 24 | } |
27 | 25 |
|
28 | 26 | /** |
29 | | - * Set rowGroup className option value. |
| 27 | + * Set rowGroup option value. |
30 | 28 | * |
31 | | - * @param string $value |
| 29 | + * @param bool|array $value |
32 | 30 | * @return $this |
33 | | - * @see https://datatables.net/reference/option/rowGroup.className |
| 31 | + * @see https://datatables.net/reference/option/rowGroup |
34 | 32 | */ |
35 | | - public function rowGroupUpdate(string $value = 'group'): static |
| 33 | + public function rowGroup(bool|array $value = true): static |
36 | 34 | { |
37 | | - return $this->rowGroup(['className' => $value]); |
| 35 | + if (is_array($value)) { |
| 36 | + $this->attributes['rowGroup'] = array_merge((array) $this->attributes['rowGroup'], $value); |
| 37 | + } else { |
| 38 | + $this->attributes['rowGroup'] = $value; |
| 39 | + } |
| 40 | + |
| 41 | + return $this; |
38 | 42 | } |
39 | 43 |
|
40 | 44 | /** |
@@ -120,4 +124,17 @@ public function rowGroupStartRender(string $value = null): static |
120 | 124 | { |
121 | 125 | return $this->rowGroup(['startRender' => $value]); |
122 | 126 | } |
| 127 | + |
| 128 | + /** |
| 129 | + * @param string|null $key |
| 130 | + * @return mixed |
| 131 | + */ |
| 132 | + public function getRowGroup(string $key = null): mixed |
| 133 | + { |
| 134 | + if (is_null($key)) { |
| 135 | + return $this->attributes['rowGroup'] ?? true; |
| 136 | + } |
| 137 | + |
| 138 | + return $this->attributes['rowGroup'][$key] ?? false; |
| 139 | + } |
123 | 140 | } |
0 commit comments