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

  • SEARCH
  • Home
  • 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 6844651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:24:16+00:00 2026-05-27T00:24:16+00:00

I use datatable plugin in a website. Normally I have only 1 datatable per

  • 0

I use datatable plugin in a website.
Normally I have only 1 datatable per page but in a special display I have 2 datable.

Actually I have this code

var oTable = $('.datatable').dataTable({
    'sPaginationType':'full_numbers',
    "iDisplayLength": 50,
    "oLanguage": {
        "sUrl": "js/locales/dataTables.french.txt"
    }
});

/* Add a click handler to the rows - this could be used as a callback */
$(".delete-ajax").click(function(event) {
    event.preventDefault();
    var answer = confirm("Supprimer l'élément ?")
    if (answer){
    var loading = $('.loading-notification');
    loading.removeClass('hidden');
        $(oTable.fnSettings().aoData).each(function (){
            $(this.nTr).removeClass('row_selected');
        });
        $(event.target).parents('tr').addClass('row_selected');
        var url = $(this).attr('href');
        var id = $(this).attr('data-ajax');
        var anSelected = fnGetSelected( oTable );
        $.ajax({
            type: "POST",
            url: url,
        data: "delete=true&id="+ id,
        async : true,
        success: function(msg) {
            loading.addClass('hidden');
            oTable.fnDeleteRow( anSelected[0] );
            }
        });
    }
});
/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal ){
    var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i<aTrs.length ; i++ ){
    if ( $(aTrs[i]).hasClass('row_selected') ){
        aReturn.push( aTrs[i] );
    }
}
return aReturn;
}

This code work well when I have only 1 datatable but when I have more I obtain In my console :

k is undefined
[Stopper sur une erreur]   h=a._iDisplayEnd;if(a.oFeatures.bServe...push(a.aoOpenRows[k].nTr)}}else{d[0]= 

Any idea on how to solve this problem ?

  • 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-05-27T00:24:16+00:00Added an answer on May 27, 2026 at 12:24 am

    Here is how you can delete a row in the table (regardless the number of amount of tables in page)

    I got two table in same page

    I am not sure about how good is the id that you gave to the table, but if its “.datatable” then:

    Add this function to your page

    $(".datatable tbody").delegate("tr", "click", function () {
        var iPos = oTable.fnGetPosition(this);
        if (iPos !== null) {
            oTable.fnDeleteRow(iPos);//delete row
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a local JSON dataset. I want to use jquery datatable plugin to
I use yui datatable and i have a field which is resumePath which is
I use yui datatable in my asp.net application... I have a link button in
I cannot use AsEnumerable() on DataTable, I'm using C# 3 but I'm just targeting
I have converted my Datatable to json string use the following method... public string
I try to use Richfaces DataTable with DataTableModel to have server side paging and
I started to use the jquery datatables plugin for asp.net mvc2. I have the
I Use Fancybox to display complex forms on an intranet site. The page the
I have a large amount of data I wish to use with Jquery DataTable
I am trying to use jquery DataTables plugin to display details from my db

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.