<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<link href="https://cdn.datatables.net/v/dt/dt-2.0.2/b-3.0.1/date-1.5.2/sl-2.0.0/datatables.min.css" rel="stylesheet">
 
<script src="https://cdn.datatables.net/v/dt/dt-2.0.2/b-3.0.1/date-1.5.2/sl-2.0.0/datatables.min.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>
    <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>Name</th>
            <th>Position</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        </thead>
        <tfoot>
          <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        </tfoot>
    </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 editor = new $.fn.dataTable.Editor({
    table: "#example",
    idSrc: 'id',
    fields: [
      {
        label: "Name:",
        name: "name",
        type: 'datatable',
        optionsPair: {
          value: 'name'
        },
        config: {
          ajax: '/ajax/objects.txt',
          columns: [
            {
              title: 'Name',
              data: 'name'
            },
          ],
        paging: false,
        scrollY: '285px',
        scrollCollapse: true,
          initComplete: function () {
            this.api().on('select', function ( e, dt, type, indexes ) {
              editor.on('open', function () { 
                dt.row(  {selected: true} ).node().scrollIntoView(true); 
              });
            })
          }
        }
      },
    ]
  });
  $("#example").DataTable({
    ajax: '/ajax/objects.txt',
    rowId: 'id',
    dom: "Bfrtip",
    displayStart: 50,
    columns: [
      { data: "name" },
      { data: "position" },
      { data: "start_date" },
      { data: "salary" }
    ],
    select: true,
    buttons: [
      { extend: "create", editor: editor },
      { extend: "edit", editor: editor },
      { extend: "remove", editor: editor }
    ]
  });
  
  
  editor
    .field('position')
  .update([{label: 'Ashton Cox', value: 'Ashton Cox'}]);
});
1 error
Line 29: Missing semicolon.
Output

This bin was created anonymously and its free preview time has expired. Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers