<!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>Col1</th>
            <th>Col2</th>
            <th>Col3</th>
            <th>Col4</th>
          </tr>
        </thead>
        <tfoot>
          <tr>
            <th>Col1</th>
            <th>Col2</th>
            <th>Col3</th>
            <th>Col4</th>
          </tr>
        </tfoot>
      </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;
}
 
var output = {
  object1: [
    {
      'col1': 'data1',
      'col2': 'data2'
    },
    {
      'col1': 'data1-2',
      'col2': 'data2-2'
    }
  ],
  object2: [
    {
      'col3': 'data3',
      'col4': 'data4'
    },
    {
      'col3': 'data3-2',
      'col4': 'data4-2'
    }
  ]
}
var table = new DataTable('#example', {
  columns: [
    {
      data: 'col1', defaultContent: ''
    },
    {
      data: 'col2', defaultContent: ''
    },
    {
      data: 'col3', defaultContent: ''
    },
    {
      data: 'col4', defaultContent: ''
    },
  ]
});
    
table.rows.add(output.object1);
table.rows.add(output.object2).draw();
    
1 error
Line 23: Missing semicolon.
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers