Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container-fluid">
  <div class="row p-md-2">
    <div class="col-sm-6">
      <table id="tblAppendGrid1"></table>
      <hr/>
      <table id="tblAppendGrid2"></table>
    </div>
    <div class="col-sm-6">
      <blockquote class="blockquote">
        <p class="mb-0">Callback logs</p>
        <footer class="blockquote-footer">Try add / remove / move up / move down rows on grids!</footer>
      </blockquote>
      <ul class="list-group" style="font-size: 0.8rem;">
      </ul>
    </div>
  </div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                var ag1 = new AppendGrid({
  element: "tblAppendGrid1",
  uiFramework: "bootstrap4",
  iconFramework: "fontawesome5",
  columns: [
    {
      name: "foo1",
      display: "Foo 1"
    },
    {
      name: "bar1",
      display: "Bar 1"
    }
  ],
  // Optional CSS classes, to make table slimmer!
  sectionClasses: {
    table: "table-sm",
    control: "form-control-sm",
    buttonGroup: "btn-group-sm"
  },
  initData: [
    {
      foo1: "Foo 1A",
      bar1: "Bar 1A"
    },
    {
      foo1: "Foo 1B",
      bar1: "Bar 1B"
    },
    {
      foo1: "Foo 1C",
      bar1: "Bar 1C"
    }
  ],
  // Grid callbacks
  dataLoaded: function(caller, records) {
    addLog(caller, "`dataLoaded` triggered, count=" + records.length);
  },
  rowDataLoaded: function(caller, record, rowIndex) {
    addLog(caller, "`rowDataLoaded` triggered, rowIndex=" + rowIndex);
  },
  afterRowAppended: function(caller, rowIndex) {
    addLog(caller, "`afterRowAppended` triggered, rowIndex=" + rowIndex);
  },
  afterRowInserted: function(caller, rowIndex) {
    addLog(caller, "`afterRowInserted` triggered, rowIndex=" + rowIndex);
  },
  afterRowSwapped: function(caller, oldRowIndex, newRowIndex) {
    addLog(
      caller,
      "`afterRowSwapped` triggered, oldRowIndex=" +
        oldRowIndex +
        ", newRowIndex=" +
        newRowIndex
    );
  },
  beforeRowRemove: function(caller, rowIndex) {
    return confirm("Are you sure to remove this row?");
  },
  afterRowRemoved: function(caller, rowIndex) {
    addLog(caller, "`afterRowRemoved` triggered, rowIndex=" + rowIndex);
  }
});
var ag2 = new AppendGrid({
  element: "tblAppendGrid2",
  uiFramework: "bootstrap4",
  uiParams: {
    sectionClasses: {
      thead: "thead-dark"
    }
  },
  iconFramework: "fontawesome5",
  columns: [
    {
      name: "foo2",
      display: "Foo 2"
    },
    {
      name: "bar2",
      display: "Bar 2"
    }
  ],
  initRows: 1,
  // Optional CSS classes, to make table slimmer!
  sectionClasses: {
    table: "table-sm",
    control: "form-control-sm",
    buttonGroup: "btn-group-sm"
  },
  // Grid callbacks
  afterRowAppended: function(caller, rowIndex) {
    addLog(caller, "`afterRowAppended` triggered, rowIndex=" + rowIndex);
  },
  afterRowInserted: function(caller, rowIndex) {
    addLog(caller, "`afterRowInserted` triggered, rowIndex=" + rowIndex);
  },
  afterRowSwapped: function(caller, oldRowIndex, newRowIndex) {
    addLog(
      caller,
      "`afterRowSwapped` triggered, oldRowIndex=" +
        oldRowIndex +
        ", newRowIndex=" +
        newRowIndex
    );
  },
  afterRowRemoved: function(caller, rowIndex) {
    addLog(caller, "`afterRowRemoved` triggered, rowIndex=" + rowIndex);
  }
});

function addLog(caller, message) {
  var $logItem = $("<li></li>")
    .addClass("list-group-item")
    .prependTo(".list-group");
  if (caller.id === "tblAppendGrid1") {
    $logItem.addClass("list-group-item-primary");
  } else if (caller.id === "tblAppendGrid2") {
    $logItem.addClass("list-group-item-success");
  }
  $("<div></div>")
    .addClass("font-weight-bold")
    .text(new Date().toLocaleTimeString() + " - " + caller.id)
    .appendTo($logItem);
  $("<div></div>")
    .text(message)
    .appendTo($logItem);
}

              
            
!
999px

Console