Bootstrap Table Toolbar Buttons

Custom Toolbar Buttons Extension

by Michael Sogos

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https:=&quot;//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.1/bootstrap-table.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.1/bootstrap-table.min.js"></script>
<script src="https://rawgit.com/michaelsogos/bootstrap-table-toolbar-buttons/master/src/bootstrap-table-toolbar-buttons.js"></script>
<div class="container">
  <div class="row">
    <table id='grid'>
      <thead>
        <tr>
          <th data-field='itemid'>Item ID</th>
          <th data-field='name'>Name</th>
          <th data-field='price'>Price</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>1</td>
          <td>ABC</td>
          <td>$1.00</td>
        </tr>
        <tr>
          <td>2</td>
          <td>DEF</td>
          <td>$2.00</td>
        </tr>
        <tr>
          <td>3</td>
          <td>GHI</td>
          <td>$3.00</td>
        </tr>
        <tr>
          <td>4</td>
          <td>XYZ</td>
          <td>$4.00</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

<!-- context menu -->
<ul id="context-menu" class="dropdown-menu">
  <li data-item="edit"><a>Edit</a></li>
  <li data-item="delete"><a>Delete</a></li>
  <li data-item="action1"><a>Action Here</a></li>
  <li data-item="action2"><a>And Action Here</a></li>
</ul>

<div id="filters-dialog" class="modal" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title ">Table Filters</h4>
      </div>
      <div class="modal-body">
        <span>Add here filter fields!</span>
      </div>
      <div...

JavaScript

$(function() {
      $('#grid').bootstrapTable({
        showRefresh: true,
        customToolbarButtons: [{
          name: "grid-filters",
          title: "Filters",
          icon: "glyphicon-filter",
          callback: onShowFiltersDialog
        },
        {
          name: "grid-email",
          title: "Email",
          icon: "glyphicon-envelope",
          callback: onShowFiltersDialog
        },
        {
          name: "grid-print",
          title: "Print",
          icon: "glyphicon-print",
          callback: onShowFiltersDialog
        }
        ]
      });
    });

    var onShowFiltersDialog = function() {
      $('#filters-dialog').modal('show');
    };