<html>
<head>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<link href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.js"></script>
<link href="https://editor.datatables.net/extensions/Editor/css/editor.dataTables.min.css" rel="stylesheet" type="text/css" />
<script src="https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js"></script>
<link href="https://nightly.datatables.net/autofill/css/autoFill.dataTables.css?_=763113f6af5ebc6856f4524627ddf7e6.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/autofill/js/dataTables.autoFill.js?_=763113f6af5ebc6856f4524627ddf7e6"></script>
<link href="https://cdn.datatables.net/buttons/1.6.0/css/buttons.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.datatables.net/buttons/1.6.0/js/dataTables.buttons.js"></script>
<link href="https://nightly.datatables.net/rowreorder/css/rowReorder.dataTables.css?_=9e78fb9f95a9b67ea132905fd3877eea.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/rowreorder/js/dataTables.rowReorder.js?_=9e78fb9f95a9b67ea132905fd3877eea"></script>
<meta charset=utf-8 />
<title>DataTables - JS Bin</title>
</head>
<body>
<div class="container">
<table id="example" class="table table-striped table-bordered" width="100%">
<thead>
<tr>
<th></th>
<th>id</th>
<th>Item Type</th>
<th>Qty</th>
<th>Supplier</th>
<th>Cat No.</th>
<th>Description</th>
<th>Cost Per Unit</th>
<th>Markup</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</body>
</html>
body {
font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
color: #333;
background-color: #fff;
}
$(document).ready( function () {
var dataSet = [{"DT_RowId":"row_62618","id":"62618","quote_id":"175299","quote_position":"1","type":"","quantity":"0.0000","brand":"","cat_number":"","description":"","cost_per_unit":"0.00","markup_perc":"0.00","note":"Chisholm TAFE Frankston Buildings A&B - Steinel Automation Package","isHeader":"yes","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62619","id":"62619","quote_id":"175299","quote_position":"2","type":"","quantity":"0.0000","brand":"","cat_number":"","description":"","cost_per_unit":"0.00","markup_perc":"0.00","note":"STEINEL 240V PRESENCE DETECTORS","isHeader":"yes","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62620","id":"62620","quote_id":"175299","quote_position":"3","type":"MD1","quantity":"38.0000","brand":"Steinel","cat_number":"","description":"M033453-MOTION DETECTOR IS 3360 ROUND COM1 CONCEALED [MD1]","cost_per_unit":"100.00","markup_perc":"0.00","note":"","isHeader":"no","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62621","id":"62621","quote_id":"175299","quote_position":"4","type":"MD2","quantity":"87.0000","brand":"Steinel","cat_number":"","description":"M032845-MOTION IS 360-1 DE WHITE [MD2]","cost_per_unit":"100.00","markup_perc":"0.00","note":"","isHeader":"no","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62622","id":"62622","quote_id":"175299","quote_position":"5","type":"MD3","quantity":"72.0000","brand":"Steinel","cat_number":"","description":"M052098-MOTION IS 2360 WHITE [MD3]","cost_per_unit":"100.00","markup_perc":"0.00","note":"","isHeader":"no","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62623","id":"62623","quote_id":"175299","quote_position":"6","type":"MD4","quantity":"16.0000","brand":"Steinel","cat_number":"","description":"M033682-MOTION DETECTOR HF 3360 ROUND COM1 CONCEALED [MD4]","cost_per_unit":"100.00","markup_perc":"0.00","note":"","isHeader":"no","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62624","id":"62624","quote_id":"175299","quote_position":"7","type":"MD5","quantity":"104.0000","brand":"Steinel","cat_number":"","description":"M002770-PRESENCE QUATTRO HD COM2 FAN CONTROL [MD5]","cost_per_unit":"100.00","markup_perc":"0.00","note":"","isHeader":"no","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62625","id":"62625","quote_id":"175299","quote_position":"8","type":"MD6","quantity":"30.0000","brand":"Steinel","cat_number":"","description":"M033446-MOTION DETECTOR IS 3360 ROUND COM1 SURFACE MOUNTED [MD6]","cost_per_unit":"100.00","markup_perc":"0.00","note":"","isHeader":"no","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62626","id":"62626","quote_id":"175299","quote_position":"10","type":"","quantity":"0.0000","brand":"","cat_number":"","description":"","cost_per_unit":"0.00","markup_perc":"0.00","note":"KNX Lighting Control System Quotation","isHeader":"yes","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62627","id":"62627","quote_id":"175299","quote_position":"11","type":"","quantity":"1.0000","brand":"Steinel","cat_number":"","description":"As per attachment","cost_per_unit":"100.00","markup_perc":"0.00","note":"","isHeader":"no","pageBreakAfter":"no","rowHighlightColour":""},{"DT_RowId":"row_62633","id":"62633","quote_id":"175299","quote_position":"9","type":"MD7","quantity":"4.0000","brand":"Steinel","cat_number":"","description":"M007935 - PRESENCE ULTRASONIC US360 [MD7]","cost_per_unit":"100.00","markup_perc":"5.00","note":"","isHeader":"no","pageBreakAfter":"no","rowHighlightColour":""}];
let editor = new $.fn.dataTable.Editor( {
//data: dataSet,
table: "#example",
idSrc: 'id',
fields: [
{
type: "hidden",
name: "quote_id",
default: 12345
},
{
type: "hidden",
name: "quote_position",
default: 0
},
{
type: "hidden",
name: "note",
default: ""
},
{
type: "hidden",
name: "rowHighlightColour",
default: ""
},
{
label: "Type",
name: "type"
},
{
label: "Quantity",
name: "quantity"
},
{
label: "Supplier",
name: "brand"
},
{
label: "Cat Number",
name: "cat_number"
},
{
label: "Description",
name: "description",
type: "textarea"
},
{
label: "Cost Per Unit",
name: "cost_per_unit"
},
{
label: "Markup Percentage",
name: "markup_perc"
}
]
} );
$('#example').on( 'click', 'tbody td', function (e) {
if ( ($(this).index() !== 7 && $(this).index() !== 9 && $(this).index() !== 10) && $(this).attr('colspan') === undefined) {
editor.inline( this );
}
} );
var table = $('#example').DataTable({
dom: "Bfrtip",
autoFill: {editor: editor},
select: {
style: 'os',
selector: 'td:last-child',
blurable: true
},
rowReorder: {
dataSrc: 'quote_position',
editor: editor
},
buttons: [
{ extend: "create", editor: editor}
],
"orderFixed": [ 1, 'asc' ],
data: dataSet,
rowId: 'id',
"columns": [
{"data": "id"},
{"data": "quote_position"},
{"data": "type"},
{"data": "quantity"},
{"data": "brand"},
{"data": "cat_number"},
{"data": "description"},
{data: "cost_per_unit",
render: function ( data, type, row ) {
return '$'+ data;
}
},
{data: "markup_perc",
render: function ( data, type, row ) {
return data + '%';
}
}
],
"columnDefs": [
{
"targets": [0],
"visible": true,
"searchable": false,
"orderable": false,
},
{
"targets": [1],
"visible": false,
"searchable": false,
"orderable": false,
}
],
"createdRow": function (row, data, dataIndex) {
let isHeader = data.isHeader;
if (isHeader === 'yes') {
$(row).html(sectionHeader(data));
}
}
});
table.on( 'order.dt search.dt', function () {
table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = i+1;
} );
} ).draw();
function sectionHeader(data) {
return '<table cellpadding="5" cellspacing="0" border="0">' +
'<tr>' +
'<td>' + data.quote_position + '</td>' +
'<td colspan="6" style="text-align:center;font-weight:bold;text-decoration: underline;">' + data.note + '</td>' +
'</tr>' +
'</table>';
}
});
You can jump to the latest bin by adding /latest
to your URL
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + [ | Indents selected lines |
ctrl + ] | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Clone Bin |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |