<!DOCTYPE html>
<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>
    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
  <body>
    <div class="container">
      <table id="example" class="display nowrap" width="100%">
        <thead>
          <tr>
            <th></th>
            <th>Name</th>
            <th>City</th>
            <th>Age</th>
            <th>Size</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td><input type="checkbox" checked></td>
            <td><input type="button" value="Tiger Nixon"></td>
            <td><input type="text" value="Edinburgh"></td>
            <td><input type="text" value="2"></td>
            <td>Small</td>
          </tr>
          <tr>
            <td><input type="checkbox"></td>
            <td><input type="button" value="Garrett Winters"></td>
            <td><input type="text" value="Paris"></td>
            <td><input type="text" value="3"></td>
            <td>large</td>
          </tr>
          <tr>
            <td><input type="checkbox"></td>
            <td><input type="button" value="Ashton Cox"></td>
            <td><input type="text" value="Kiev"></td>
            <td><input type="text" value="4"></td>
            <td>medium</td>
          </tr>
          <tr>
            <td><input type="checkbox" checked></td>
            <td><input type="button" value="Cedric Kelly"></td>
            <td><input type="text" value="Shanghi"></td>
            <td><input type="text" value="5"></td>
            <td>Small</td>
          </tr>
        </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;
}
 
$.fn.dataTable.ext.order['dom-checkbox'] = function (settings, col) {
  return this.api().column(col, { order: 'index' }).nodes().map(function (td, i) {
    return $('input', td).prop('checked') ? '1' : '0';
  });
}
$.fn.dataTable.ext.order['dom-text'] = function  ( settings, col )
{
    return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
        return $('input', td).val();
    } );
}
$(document).ready(function () {
  $('#example').dataTable({
    "columns": [
      { "orderDataType": "dom-checkbox" },
      { "orderDataType": "dom-text", type: 'string' },
      { "orderDataType": "dom-text", type: 'string' },
      { "orderDataType": "dom-text", type: 'string' },
      null,
    ],
  });
});
2 errors
Line 5: Missing semicolon.
Line 11: Missing semicolon.
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers