Example 18:

This example show you how to:

  • Load the plugin
  • Prepend some data to the mSelect


HTML:
<select id="country_id" class="mSelect" multiple="multiple"></select>
JS:
$(function () {
    $('#country_id').mSelect({
        url: 'ajax/example1.php',
        prependData: {'null': 'Undefined'} // prepend an Undefined value
    });
});
PHP :
<?php 
    //........
    //........
    $response = Datatables::complex($_GET, $sql_details, $table, $primaryKey, $columns, $whereResult = null, $whereAll = null);
    
    if(isset($_GET['prependData'])){
        foreach ($_GET['prependData'] as $key => $value) {
            array_unshift($response['data'], [$key, $value]);
        }
    }
    
    echo json_encode($response);
?>