This example show you how to:
<select id="country_id" class="mSelect" multiple="multiple"></select>
$(function () {
$('#country_id').mSelect({
url: 'ajax/example4.php',
selectedIds: ["3","4","14","231","109"], // the ids to select by default
btnSelected:{
enable: true
},
cssNotEmpty: 'background:yellow;border:1px solid blue'
});
});
<?php
//........
// get the selected rows ids
$selectedIds = isset($_GET['ids']) && !empty($_GET['ids']) ? $_GET['ids'] : [];
$whereResult = !empty($selectedIds) ? "id IN($selectedIds)" : null;
echo json_encode(
Datatables::complex($_GET, $sql_details, $table, $primaryKey, $columns, $whereResult, $whereAll = null)
);
?>