1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
var table = $('#example').DataTable({
dom: 'Bfrtip',
"searching": false,
"paging": false,
ajax: '/jquery03/MyServlet2',
columns: [{
data: 'readingOrder',
className: 'reorder'
}, {
data: 'title'
}, {
data: 'author'
}, {
data: 'duration',
render: function(data, type, row) {
return parseInt(data / 60, 10) + 'h ' + (data % 60) + 'm';
}
}],
columnDefs: [{
orderable: false,
targets: [1, 2, 3]
}],
rowReorder: {
dataSrc: 'readingOrder',
editor: editor
},
select: true,
});
editor
.on('postCreate postRemove', function() {
// After create or edit, a number of other rows might have been effected -
// so we need to reload the table, keeping the paging in the current position
table.ajax.reload(null, false);
})
.on('initCreate', function() {
// Enable order for create
editor.field('readingOrder').enable();
})
.on('initEdit', function() {
// Disable for edit (re-ordering is performed by click and drag)
editor.field('readingOrder').disable();
});
});
sendAja11 = function() {
var data;
if ($.fn.dataTable.isDataTable('#example')) {
data = $('#example').DataTable();
} else {
data = $('#example').DataTable({
paging: false
});
}
$.ajax({
type: 'post',
cache: false,
url: '/jquery03/MyServlet2',
data: function(d) {
return {
'd': JSON.stringify(d)
};
}
});
} |
Partager