Data table with paging and selection

Present a data table with paging and selection checkboxes.

This example continues on the previous example Data table with paging where we created a data table with paging using a form that is automatically submitted when a form control is changed.

In this example we will add checkboxes to select rows of the table. Since the form has an onchange-submit class, any change on a form control will immediately submit the form. To avoid form submission when checking or unchecking selection checkboxes, we can remove the onchange-submit class from the FORM element, and add it only to those controls that should submit the form on change.

Alternatively, we can leave the onchange-submit class on the FORM element as default behavior, and add the class onchange-nosubmit on those form controls that should not submit the form on change. This is how it is done in the following code:

<form action="/Customers" class="onchange-submit target">

  <div class="table-responsive">
    <div class="overlay" hidden></div>
    <table class="table">
            <input type="checkbox" class="onchange-nosubmit"
                   ifunchecked-uncheck="<TABLE|>[name='selection']" >
            <input type="checkbox" name="selection" value="1"
          <td>A Bike Store</td>
            <input type="checkbox" name="selection" value="2"
          <td>Progressive Sports</td>
            <input type="checkbox" name="selection" value="3"
          <td>Advanced Bike Components</td>
  <select name="pagesize" class="form-control float-end" style="width: 52px;">
    <option selected="selected">3</option>
    <ul class="pagination">
      <li class="page-item active">
        <label class="page-link">
          <input type="radio" name="page" value="1">
      <li class="page-item">
        <label class="page-link">
          <input type="radio" name="page" value="2">
      <li class="page-item">
        <label class="page-link">
          <input type="radio" name="page" value="3">
    <button type="submit" class="btn btn-primary"
            enable-ifanychecked="<FORM|>[name='selection']" >
      <i class="spinner fas fa-download"></i>


In the header how, we add a checkbox without name but with ifchecked-check and ifunchecked-uncheck attributes to have the row selection checkboxes follow this checkbox.

At the end, the Export button is only enabled when at least one selection checkbox is checked. This is achieved with the action-event attribute enable-ifchecked which takes a (relative) CSS selector.

The "<FORM|>[name='selection']" selector is a relative CSS selector searching for its parent FORM element, and from there off select all children elements with name "selection".


Working demo
Loading demo...



This example requires following Sircl library files to be loaded:


Or their non-minified counterparts.

See the Get Started section about how to set up your project to use the Sircl library.