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

Commit75c773c

Browse files
committed
Implement buttons support for editor.
As per PRyajra/laravel-datatables#1105.
1 parent385f66b commit75c773c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎src/Html/Builder.php‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public function parameterize($attributes = [])
172172
list($ajaxDataFunction,$parameters) =$this->encodeAjaxDataFunction($parameters);
173173
list($columnFunctions,$parameters) =$this->encodeColumnFunctions($parameters);
174174
list($callbackFunctions,$parameters) =$this->encodeCallbackFunctions($parameters);
175+
list($editorButtons,$parameters) =$this->encodeEditorButtons($parameters);
175176

176177
$json =json_encode($parameters);
177178

@@ -180,10 +181,47 @@ public function parameterize($attributes = [])
180181
$json =$this->decodeAjaxDataFunction($ajaxDataFunction,$json);
181182
$json =$this->decodeColumnFunctions($columnFunctions,$json);
182183
$json =$this->decodeCallbackFunctions($callbackFunctions,$json);
184+
$json =$this->decodeEditorButtons($editorButtons,$json);
183185

184186
return$json;
185187
}
186188

189+
190+
/**
191+
* Encode DataTables editor buttons.
192+
*
193+
* @param array $parameters
194+
* @return array
195+
*/
196+
protectedfunctionencodeEditorButtons(array$parameters)
197+
{
198+
$editorButtons = [];
199+
if (isset($parameters['buttons'])) {
200+
foreach ($parameters['buttons']as$i =>$button) {
201+
if (isset($button['editor'])) {
202+
$editorButtons[$i] =$this->compileCallback($button['editor']);
203+
$parameters['buttons'][$i]['editor'] ="#editor_button.{$i}#";
204+
}
205+
}
206+
}
207+
return [$editorButtons,$parameters];
208+
}
209+
210+
/**
211+
* Decode DataTables Editor buttons.
212+
*
213+
* @param array $editorButtons
214+
* @param string $json
215+
* @return string
216+
*/
217+
protectedfunctiondecodeEditorButtons(array$editorButtons,$json)
218+
{
219+
foreach ($editorButtonsas$i =>$function) {
220+
$json =str_replace("\"#editor_button.{$i}#\"",$function,$json);
221+
}
222+
return$json;
223+
}
224+
187225
/**
188226
* Get table computed table attributes.
189227
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp