Extension of jquery.dataTables plugin for multi selection.
If you are using jquery.dataTables 1.10.8 or above, use Select and AreaSelect extensions.
For code sample check out the index.html file or go to live demo.
Minimal browser compatibility
Web browser | Version |
---|---|
Chrome | Ok |
Firefox | v3.5 |
IE | v9 |
Opera | v10 |
Safari | v4 |
Dependencies
jQuery v1.11.3 at least. Works perfectly on higher versions.
jquery.dataTables v1.10.7 or higher version without the Select extension.
Features
- Drag & drop onto table row to select a range of rows.
- Selected rows are styled.
- Hold Ctrl to add item to an existing selection.
- dataTables trigger "selectionChanged.dt" event and send data rows array to callback.
- You can enable/disable selection by code with the function: selectable(bool)
- Allow multiple instance of selectable dataTables on the same page.
Usages
<!-- reference both css and js files -->
<link href="css/jquery.dataTables.multiselect.css" rel="stylesheet">
<script src="js/jquery.dataTables.multiselect.js"></script>
<!-- Add a table to your page -->
<table id="my_table"></table>
$("#my_table")
// initializes dataTable as usual
.dataTable({
data: ...,
columns: [ ... ],
initComplete: function () {
// enables multi selection extension
$("#my_table").enableExtendedSelection();
}
})
// binds callback to selection change event
.on("selectionChanged.dt", function (event, params) {
console.info("Selection", params.data);
});
// to get the current selection by code
var arr = $("#my_table").data().selection.items;
// Disable/enable multiselection
$("#my_table").selectable(false/true);
Callback events
Event | Description |
---|---|
selectionChanged.dt | Triggered when the selection changed. |
Released under the MIT license.