<!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">
      <button id="addRow">Add new row</button>
      <table id="table1" class="display nowrap" width="100%"></table>
      <table id="table2" class="display nowrap" width="100%">
        <thead>
          <tr>
            <th>Select</th>
            <th>ResponsibilityID</th>
            <th>Responsibility</th>
          </tr>
        </thead>
         
      </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 Table1 = $('#table1').DataTable({
        columns: [
            {
                data: null, title: "Select",
                render: function (data, type, row) {
                    if (type === 'display') {
                        return '<input type="checkbox" class="editor-active">';
                    }
                    return data;
                },
                className: "text-center"
            },
            { data: null, title: "ResponsibilityID" },
            { data: null, title: "Responsibility" }
        ]    
  });
var Table2 = $('#table2').DataTable();
    $('#addRow').on('click', function () {
//        var data = arrResponsibilities.responseJSON.data;
var data = 
    [
    {
        "DT_RowId": "row_50022",
        "RESPONSIBILITY_ID": 50022,
        "RESPONSIBILITY_NAME": "STAN CASH MANAGEMENT SUPERUSER",
        "CategoryID": 6
    },
    {
        "DT_RowId": "row_50023",
        "RESPONSIBILITY_ID": 50023,
        "RESPONSIBILITY_NAME": "STAN CASH MGT TREASURY",
        "CategoryID": 5
    },
    {
        "DT_RowId": "row_50024",
        "RESPONSIBILITY_ID": 50024,
        "RESPONSIBILITY_NAME": "STAN CASH MGT RECONCILIATION",
        "CategoryID": 5
    }
];
        $.each(data, function (key, value) {
            Table1.row.add([ 0, value.RESPONSIBILITY_ID, value.RESPONSIBILITY_NAME ]);
            Table2.row.add([ 0, value.RESPONSIBILITY_ID, value.RESPONSIBILITY_NAME ]);
        });
        Table1.draw();
        Table2.draw();
    });
  
  
  } );
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers