Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!doctype html>
<html lang="en">

<head>
  <title>SI Portal</title>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css">
  <link rel="stylesheet" href="https://cdn.datatables.net/scroller/2.0.1/css/scroller.bootstrap4.min.css">
  <script src="https://kit.fontawesome.com/f8c90c2c97.js" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="index.css">

</head>

<body>

  <main class="container-fluid">
    <div class="row">
      <div class="col m-3" id="document-list">
        <h1 class="text-center text-lg-left">Document List</h1>
        <table id="document-table" class="display" style="width: auto">
          <thead>
            <tr>
              <th>#</th>
              <th>Document Name</th>
              <th>Document Type</th>
              <th>Version</th>
              <th>Department</th>
              <th>Published Date</th>
              <th class="text-center">Actions</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
            </tr>
          </tbody>
          <tfoot>
            <small>Hold the <i>Shift</i> key while sorting to enable multiple sort</small>
          </tfoot>
        </table>
      </div>
    </div>
  </main>

  <!-- Optional JavaScript -->
  <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
  </script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
  </script>
  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.js">
  </script>
  <script src="https://cdn.datatables.net/scroller/2.0.1/js/dataTables.scroller.min.js"></script>
  <script src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/ellipsis.js"></script>
  <script>
    $.getJSON('test.json', function(data) {
      console.log(data["documents"][0])
    });
    // Data table initialization
    $(document).ready(function() {
      $('#document-table').DataTable({
        order: [],
        ajax: {
          url: 'https://api.myjson.com/bins/19ltu3',
          dataSrc: 'documents'
        },
        orderMulti: true,
        responsive: true,
        scrollY: 500,
        deferRender: true,
        scroller: true,
        columns: [{
            data: "id"
          },
          {
            data: "name"
          },
          {
            data: "type"
          },
          {
            data: "version"
          },
          {
            data: "department"
          },
          {
            data: "date"
          }
        ],
        columnDefs: [{
            // Disable filtering for ID, doctype, department and actions
            targets: [0, 2, 4, 6],
            orderable: false
          },
          {
            // Disable searching for actions
            targets: [6],
            searchable: false
          },
          {
            // Display ellipses for long document names
            targets: 1,
            width: "300px",
            render: function(data, type, row) {
              return type === 'display' && data.length > 30 ?
                data.substr(0, 50) + '…' :
                data;
            }
          },
          {
            targets: 4,
            render: function(data, type, row) {
              return type === 'display' && data.length > 10 ?
                data.substr(0, 20) + '…' :
                data;
            }
          },
          {
            targets: [0, 2, 3, 4, 5, 6],
            width: "150px"
          },
          {
            // Automatically generate the download and preview button
            targets: 6,
            // No data source but will generate button anyways
            data: null,
            render: function(data, type, row, meta) {
              return `<div class="btn-group">
                                    <a class="btn btn-sm btn-primary" href="#" role="button">
                                        <i class="fas fa-info"></i>
                                    </a>
                                    <a class="btn btn-dark btn-sm" href="#" role="button">
                                        <i class="fas fa-download"></i>
                                    </a>
                                    <a class="btn btn-warning btn-sm" href="#" role="button">
                                        <i class="far fa-eye"></i>
                                    </a>
                                </div>`
            }
          },
          {
            targets: [0, 2, 3, 4, 5, 6],
            className: 'text-center'
          }
        ]
      });
      $.fn.dataTable.render.ellipsis = function(cutoff, wordbreak, escapeHtml) {
        var esc = function(t) {
          return t
            .replace(/&/g, '&amp;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;')
            .replace(/"/g, '&quot;');
        };
        return function(d, type, row) {
          // Order, search and type get the original data
          if (type !== 'display') {
            return d;
          }
          if (typeof d !== 'number' && typeof d !== 'string') {
            return d;
          }
          d = d.toString(); // cast numbers
          if (d.length < cutoff) {
            return d;
          }
          var shortened = d.substr(0, cutoff - 1);
          // Find the last white space character in the string
          if (wordbreak) {
            shortened = shortened.replace(/\s([^\s]*)$/, '');
          }
          // Protect against uncontrolled HTML input
          if (escapeHtml) {
            shortened = esc(shortened);
          }
          return '<span class="ellipsis" title="' + esc(d) + '">' + shortened +
            '&#8230;</span>';
        };
        console.log(d);
      };
    });
  </script>
</body>

</html>
            
          
!
            
              .btn-sm {
    min-width: 32px !important;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console