<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
<link href="https://nightly.datatables.net/select/css/select.dataTables.css?_=8ea1d5b678dd00be41e436bae1f50c24.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/select/js/dataTables.select.js?_=8ea1d5b678dd00be41e436bae1f50c24"></script>
<link href="https://nightly.datatables.net/buttons/css/buttons.dataTables.css?_=a2f2f3edc9718bb6bdb965c105d22ce3.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/buttons/js/dataTables.buttons.js?_=a2f2f3edc9718bb6bdb965c105d22ce3"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/selectize.js/0.9.0/css/selectize.css" rel="stylesheet" type="text/css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/selectize.js/0.9.0/js/standalone/selectize.js"></script>
<link href="http://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>
<meta charset=utf-8 />
<title>DataTables - JS Bin</title>
</head>
<body>
<div class="container">
<table id=tbl>
<thead>
<tr>
<th></th>
<th>col0</th>
<th>col1</th>
<th>col2</th>
</tr>
</thead>
</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;
}
div.selectize-dropdown {
z-index: 12;
}
(function ($, DataTable) {
if ( ! DataTable.ext.editorFields ) {
DataTable.ext.editorFields = {};
}
var Editor = DataTable.Editor;
var _fieldTypes = Editor ?
Editor.fieldTypes :
DataTable.ext.editorFields;
_fieldTypes.selectize = {
_addOptions: function ( conf, options ) {
var selectize = conf._selectize;
selectize.clearOptions();
selectize.addOption( options );
selectize.refreshOptions(false);
},
create: function ( conf ) {
var container = $('<div/>');
conf._input = $('<select/>')
.attr( $.extend( {
id: conf.id
}, conf.attr || {} ) )
.appendTo( container );
conf._input.selectize( $.extend( {
valueField: 'value',
labelField: 'label',
dropdownParent: 'body'
}, conf.opts ) );
conf._selectize = conf._input[0].selectize;
if ( conf.options || conf.ipOpts ) {
_fieldTypes.selectize._addOptions( conf, conf.options || conf.ipOpts );
}
return container[0];
},
get: function ( conf ) {
return conf._selectize.getValue();
},
set: function ( conf, val ) {
return conf._selectize.setValue( val );
},
enable: function ( conf ) {
conf._selectize.enable();
$(conf._input).removeClass( 'disabled' );
},
disable: function ( conf ) {
conf._selectize.disable();
$(conf._input).addClass( 'disabled' );
},
// Non-standard Editor methods - custom to this plug-in
inst: function ( conf ) {
return conf._selectize;
},
update: function ( conf, options ) {
_fieldTypes.selectize._addOptions( conf, options );
}
};
})(jQuery, jQuery.fn.dataTable);
var data = [];
for (i = 1; i < 4; i++) {
data.push({
id: i,
a: 'a' + i,
b: 'b' + i,
c: 'c' + i
});
}
var optvalues = [
{label:'aaaa', value:'aaaa'},
{label:'bbbb', value:'bbbb'},
{label:'ccaa', value:'ccaa'}
];
var editor = new $.fn.dataTable.Editor({
table: '#tbl',
idSrc: 'id',
fields: [
{ label: 'col1', name: 'col1' },
{ label: 'col0', name: 'col0',
type: 'selectize', options: optvalues,
},
{ label: 'col2', name: 'col2' },
],
} );
var table = $('#tbl')
.DataTable({
dom: 'lBfrtip',
data: data,
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: 'a', className: 'dt-body-center' },
{ data: 'b', className: 'dt-body-center' },
{ data: 'c', className: 'dt-body-center' }
],
select: true,
buttons: [
{ extend: 'create', editor: editor },
],
});
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. |