File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -358,4 +358,12 @@ $this->Datatable->setCallbackCreatedRow(
358358 }
359359 }'
360360);
361- ``
361+ ```
362+
363+ # Change library of multiselect
364+
365+ The default is jquery-ui multiselect, if you want to change this you can change it in the configuration or like the code example below
366+
367+ ``` php
368+ $this->Datatable->getInstance()->setConfig('multiSelectType', 'select2');
369+ ```
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ class Datatable
7676 'headersAttrsTr ' => [],
7777 'headersAttrsTh ' => [],
7878 ],
79+ 'multiSelectType ' => 'jquery-ui ' ,
7980 'rowActions ' => [
8081 'name ' => 'actions ' ,
8182 'orderable ' => 'false ' ,
@@ -312,21 +313,25 @@ class Datatable
312313 :onCompleteCallback
313314 //column search
314315 :columnSearch
316+
317+ :multiSelectCallback
315318 },
316319 });
317320
318321 dt.css(:tableCss);
319- if( jQuery.isFunction( 'select2' ) ) {
320- $(function(){
321- $(function(){
322- // for execute the select2 plugin after all events are loaded
323- $('.form-select-multiple').select2();
324- });
325- });
326- }
327322 });
328323 DATATABLE_CONFIGURATION ;
329324
325+ protected $ datatableJqueryUITemplate = <<<JQUERYUI_CONFIGURATION
326+ if ($.fn.multiselect) { $(function(){ $('.form-select-multiple').multiselect(); }); }
327+ JQUERYUI_CONFIGURATION ;
328+
329+
330+ protected $ datatableSelect2Template = <<<SELECT2_CONFIGURATION
331+ if($.fn.select2) { $(function(){ $('.form-select-multiple').select2();}); }
332+ SELECT2_CONFIGURATION ;
333+
334+
330335 /**
331336 * @param Helper $Helper
332337 */
@@ -462,6 +467,7 @@ public function getDatatableScript(): string
462467 'onCompleteCallback ' => $ this ->getConfig ('onCompleteCallback ' ) ? $ this ->getConfig ('onCompleteCallback ' ) : 'null ' ,
463468 'columnSearch ' => $ this ->getConfig ('columnSearch ' ) ? $ this ->columnSearchTemplate : '' ,
464469 'tableCss ' => json_encode ($ this ->getConfig ('tableCss ' )),
470+ 'multiSelectCallback ' => $ this ->getConfig ('multiSelectType ' ) === 'jquery-ui ' ? $ this ->datatableJqueryUITemplate : $ this ->datatableSelect2Template ,
465471 ];
466472
467473 if ($ this ->getConfig ('createdRow ' )) {
You can’t perform that action at this time.
0 commit comments