@@ -172,6 +172,7 @@ public function parameterize($attributes = [])
172
172
list ($ ajaxDataFunction , $ parameters ) = $ this ->encodeAjaxDataFunction ($ parameters );
173
173
list ($ columnFunctions , $ parameters ) = $ this ->encodeColumnFunctions ($ parameters );
174
174
list ($ callbackFunctions , $ parameters ) = $ this ->encodeCallbackFunctions ($ parameters );
175
+ list ($ editorButtons , $ parameters ) = $ this ->encodeEditorButtons ($ parameters );
175
176
176
177
$ json = json_encode ($ parameters );
177
178
@@ -180,10 +181,47 @@ public function parameterize($attributes = [])
180
181
$ json = $ this ->decodeAjaxDataFunction ($ ajaxDataFunction , $ json );
181
182
$ json = $ this ->decodeColumnFunctions ($ columnFunctions , $ json );
182
183
$ json = $ this ->decodeCallbackFunctions ($ callbackFunctions , $ json );
184
+ $ json = $ this ->decodeEditorButtons ($ editorButtons , $ json );
183
185
184
186
return $ json ;
185
187
}
186
188
189
+
190
+ /**
191
+ * Encode DataTables editor buttons.
192
+ *
193
+ * @param array $parameters
194
+ * @return array
195
+ */
196
+ protected function encodeEditorButtons (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
+ protected function decodeEditorButtons (array $ editorButtons , $ json )
218
+ {
219
+ foreach ($ editorButtons as $ i => $ function ) {
220
+ $ json = str_replace ("\"#editor_button. {$ i }# \"" , $ function , $ json );
221
+ }
222
+ return $ json ;
223
+ }
224
+
187
225
/**
188
226
* Get table computed table attributes.
189
227
*
0 commit comments