Using the Table-multiple-sort feature in boostrap-table is not functioning properly when there are multiple tables present on a single page

I have implemented bootstrap-table along with the extension table-multiple-sort. The issue I am facing is when I include two tables on a single page (with the second table within a modal window), the multisort feature does not seem to work on the second table.

jsfiddle

html

<table ref="mainTable" className="table table-striped table-bordered table-hover" cellSpacing="0" id="mainTable" data-show-toggle="true" data-show-columns="true" data-search="true" data-pagination="true">
             <thead>
                <tr>
                   <th data-field="state" data-checkbox="true"></th>
                   <th data-field="Customer Name" data-halign="center"
                      data-align="left" data-sortable="true">Customer Name</th>
                   <th data-field="Location Type" data-halign="center"
                      data-align="left" data-sortable="true">Location Type</th>
                   <th data-field="Location" data-halign="center"
                      data-align="left" data-sortable="true">Location</th>
                </tr>
             </thead>
             <tbody>
                <tr>
                   <td></td>
                   <td>Cap Corp</td>
                   <td>Main</td>
                   <td>Norwalk CT 06851</td>
                </tr>
                <tr>
                   <td></td>
                   <td>Cap Corp</td>
                   <td>Other</td>
                   <td>Norwalk CT 06851</td>
                </tr>
                <tr>
                   <td></td>
                   <td>Tel</td>
                   <td>Main</td>
                   <td>Slough SL1 4DX</td>
                </tr>
                <tr>
                   <td></td>
                   <td>Tel</td>
                   <td>Other</td>
                   <td>London W1B 5HQ</td>
                </tr>
             </tbody>
          </table>



<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <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" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        <table class="table table-striped table-bordered table-hover"  cellspacing="0" id="modalTable" data-click-to-select="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-pagination="true">
    <thead>
    <tr>
        <th data-field="state" data-checkbox="true"></th>
        <th data-field="name">Name</th>
        <th data-field="stargazers_count">Stars</th>
        <th data-field="forks_count">Forks</th>
    </tr>
    </thead>
            <tbody>
                <tr>
                   <td></td>
                   <td>ala</td>
                   <td>234</td>
                   <td>Norwalk CT 06851</td>
                </tr>
                <tr>
                   <td></td>
                   <td>ala</td>
                   <td>234</td>
                   <td>Norwalk CT 06851</td>
                </tr>
                <tr>
                   <td></td>
                   <td>ala</td>
                   <td>234</td>
                   <td>Slough SL1 4DX</td>
                </tr>
                </tbody>
    </table>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

javascript

$('#mainTable').bootstrapTable({
    showFilter: true,
    showMultiSort: true
});

$('#modalTable').bootstrapTable({
    showFilter: true,
    showMultiSort: true
  });

Answer №1

It seems that your modal table headers are missing a crucial attribute - data-sortable="true":

<thead>
    <tr>
        <th data-field="state" data-checkbox="true"></th>
        <th data-field="Customer Name" data-halign="center"
            data-align="left" data-sortable="true">Customer Name</th>
        <th data-field="Location Type" data-halign="center"
            data-align="left" data-sortable="true">Location Type</th>
        <th data-field="Location" data-halign="center"
            data-align="left" data-sortable="true">Location</th>
    </tr>
</thead>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Beware, search for DomNode!

I attempted to create a select menu using material-ui and React const SelectLevelButton = forwardRef((props, ref) => { const [stateLevel, setStateLevel] = useState({ level: "Easy" }); const [stateMenu, setStateMenu] = useState({ isOpen ...

Experiencing prolonged delays with PHP/AJAX login process

Recently, I took over the maintenance of a website that requires users to log in. However, I've noticed that the login process is quite slow, especially when there are around 4000 registered users. The current login system utilizes a combination of A ...

Obtain the query response time/duration using react-query

Currently utilizing the useQuery function from react-query. I am interested in determining the duration between when the query was initiated and when it successfully completed. I have been unable to identify this information using the return type or para ...

Utilize jQuery to export HTML or JSON data to an Excel spreadsheet

I am looking for a way to export json or html data to an excel sheet using only html and jquery, without involving any server code. I have found some fiddles that allow me to download the excel sheet successfully, but unfortunately, none of them work in In ...

JQuery script showing no signs of functioning, even though it runs smoothly in the console

I'm looking to create a clickable div for the Nivo slider on this website so visitors can easily navigate to a featured article. To debug the issues, I wrote the following script in Chrome's console: var $j = jQuery.noConflict(); $j(function(){ ...

Maximizing the performance of plotting hundreds or thousands of series in a 2D scatter or line chart using Echarts

Plotting a large data set with hundreds or thousands of series using Echarts has proven to be slow and challenging to manage. If you take a look at the example code provided in this large and progressive options on single series instead of all plotted se ...

Retrieve all elements from an array using jQuery

How do I extract all the elements from the array outside of the function? $.each(Basepath.Templates, function(i){ templateArray = new Array({title: Basepath.Templates[i].Template.name, src: 'view/'+Basepath.Templates[i].Template.id, descri ...

"Exploring the interactivity of touch events on JavaScript

Hi there, I'm currently facing an issue with the touch events on my canvas. While the mouse events are functioning correctly and drawing as expected, incorporating touch events seems to be causing a problem. When I touch the canvas, the output remains ...

Ways to remove the initial row of inline-block divs

My webpage is filled with inline-block divs that are contained within a larger div like so: <div class="container"> <div class="text">Text 1</div> <div class="text">Text 2 ... rest of the nu ...

Detailed enrollment procedure

I am facing an issue with the code in my HTML that validates input types. The system detects empty fields and prevents proceeding to the next step. How can I disable this validation as some of the fields are not required? For instance, the input type < ...

Looping through an array of JSON objects in Javascript results in finding instances, however, the process records them

Currently, I am executing a script inside a Pug template. The script commences by fetching an array of JSON objects from MongoDB. I then stringify the array (data) and proceed to loop through it in order to access each individual JSON object (doc). Subsequ ...

What is the method for retrieving the locale value from the configuration in Next.js?

How can I retrieve the i18n.defaultLocale value from my Next.js app configuration? I thought it would be simple, but I'm struggling to find a clear solution for accessing the config settings in Next.js. Is there a specific built-in method for this, or ...

Can I construct an html table-esque layout employing fabric js?

https://i.stack.imgur.com/Zwkj3.jpg I'm in the process of developing a schema builder inspired by vertabelo. To achieve this, I've opted to utilize fabric.js for its interactive features. My main challenge lies in creating an HTML table-like str ...

The NextJs image entered into an endless loop, throwing an error message that said: "The 'url' parameter is correct, but the response from the

I have been using next/image component with next js version ^12.2.3-canary.17 for my current project. The issue I am encountering is that some images are missing from the source directory, resulting in infinite error logs like the one shown below: https:/ ...

Integrate ThreeJs models into an Angular JS application

I have a question that pertains to my webapp development. I am currently utilizing Angular Js (v1.5/1.6) and I would like to incorporate some minimalistic 3D animated models by integrating Three Js. Although I have attempted to configure certain aspects, ...

The issue with Angular-gettext is that it fails to update dynamically generated strings in the code

Whenever I try to set the language using the code gettextCatalog.setCurrentLanguage(langString);, it doesn't seem to affect my side-nav menu. My side menu has two possible states: expanded or collapsed, and I use ng-include to control its content base ...

Vue function displays 'undefined' message

Although many posts on this topic exist already, I am struggling to understand what is going wrong (even after searching extensively here and on Google). I have created my interceptor like this, but I keep receiving an error message stating "This is undef ...

Generate text in a random spot effortlessly

After doing some research on various development platforms, I stumbled upon this JSFiddle that seems to have a solution for my requirements. The only thing missing is the ability to input a specific word (without user input) and automate the process at fix ...

Setting Default Value for Autocomplete in React

I'm facing an issue with the default value in my autocomplete feature within my React app. Even though I set a default value, when I try to submit the form, it still shows as invalid because it appears to have no value until I manually click on the au ...

Choose the Nth option in the dropdown list using programming

Currently, I have a script that dynamically populates a select box with unknown values and quantities of items. I am looking to create another script that mimics the action of selecting the Nth item in that box. Despite my research, I have been unable to ...