Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:31:49+00:00 2026-06-17T21:31:49+00:00

so, I am using datatables along with jQuery, and am a bit stumped as

  • 0

so, I am using datatables along with jQuery, and am a bit stumped as to why this is not working. My HTML looks like this:

<table id="surnamePrimaryPartitionTable" border=1 class="display partitionDisplay">
  <caption>Partitions</caption>
  <thead>
    <tr style="background-color: #afeeee;">
      <th>Partition</th>
      <th>CPU %</th>
      <th>Search Count</th>
      <th>Person Count</th>
      <th>Disk Space</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>

I have several tables, each of which follows a similar format, and each of which uses the partitionDisplay class (really just a class that I use so that I can select all the tables later using jQuery).

So, the problem arises when I try to destroy the datatables. Here is what I have:

function DeletePartitionInformation(data) {
  jQuery(".partitionDisplay").each(function(){
    jQuery(this).dataTable().fnDestroy();
  });
  jQuery("table tbody").each(function() {
    jQuery(this).html("");
  })
}

This code seems to work correctly for the first table, but throws an exception and doesn’t work on any subsequent tables. The javascript error message I am getting is the following:

Uncaught TypeError: Cannot read property ‘asSorting’ of undefined

A quick Google search on this error says that it generally arises from having elements nested in a tag. This does not appear to be the problem, however. I will post the code for the other three tables to demonstrate this:

<table id="surnamePrimarySubpartitionTable" border=1 class="display partitionDisplay">
  <caption>SubPartitions</caption>
  <thead>
    <tr style="background-color: #afeeee;">
      <th>Partition</th>
      <th>SubPartition</th>
      <th>CPU %</th>
      <th>Search Count</th>
      <th>Person Count</th>
      <th>Disk Space</th>
      <th>Begin</th>
      <th>End</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>

<table id="givenNullSurnamePartitionTable" border=1 class="display partitionDisplay">
  <caption>Partitions</caption>
  <thead>
    <tr style="background-color: #98fb98;">
      <th>Partition</th>
      <th>CPU %</th>
      <th>Search Count</th>
      <th>Person Count</th>
      <th>Disk Space</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>

<table id="givenNullSurnameSubpartitionTable" border=1 class="display partitionDisplay">
  <caption>SubPartitions</caption>
  <thead>
    <tr style="background-color: #98fb98;">
      <th>Partition</th>
      <th>SubPartition</th>
      <th>CPU %</th>
      <th>Search Count</th>
      <th>Person Count</th>
      <th>Disk Space</th>
      <th>Begin</th>
      <th>End</th>
  </tr>
  </thead>
  <tbody>
  </tbody>
</table>

One final note: I am actually able to get the behavior I want if I use the below code. Obviously I would prefer not to, however, since I’d really like to loop over the elements rather than hard-code the element id’s in.

function DeletePartitionInformation(data) {
  jQuery("#surnamePrimarySubpartitionTable").dataTable().fnDestroy();
  jQuery("#surnamePrimaryPartitionTable").dataTable().fnDestroy();
  jQuery("#givenNullSurnameSubpartitionTable").dataTable().fnDestroy();
  jQuery("#givenNullSurnamePartitionTable").dataTable().fnDestroy();

  jQuery("table tbody").each(function() {
      jQuery(this).html("");
  })
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:31:50+00:00Added an answer on June 17, 2026 at 9:31 pm

    Uncaught TypeError: Cannot read property ‘asSorting’ of undefined

    This seems to suggest it may be trying to destroy dataTables that weren’t created.

    The static fnTables should give you an Array of only the <table> elements with a dataTable:

    var tables = $.fn.dataTable.fnTables(true);
    
    $(tables).each(function () {
        $(this).dataTable().fnDestroy();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a simple search table (eventually using jquery Datatables) for our knowledgebase. I'm
I am using the jQuery DataTables plugin. I would like to move the search
I am using JQuery-DataTables-Editable-1.3 along with DataTables-1.9.4. I am able to add the add_delete_toolbar.
I am using Datatables Collapsible/Expandable Grouping. http://jquery-datatables-row-grouping.googlecode.com/svn/trunk/collapsibleGroups.html I have configured it so that all
I'm using datatables along with Jquery Mobile (server Coldfusion8, MySQL 5.0.88) to display tabular
I have started using the DataTables plugin (v1.6.2) for jQuery (v1.4.2), and I would
I'm using http://datatables.net/examples/ for easy control table. I'm generating table with more than 30,000
I am using the jQuery DataTables plugin to do filtering on a set of
I am using DataTables (jQuery plugin) to display my tabular data. If fetches data
I am developing a webapp using Spring, jsp, javascript, jquery. I display a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.