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 8953333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:04:22+00:00 2026-06-15T14:04:22+00:00

we have a table in our page, with a few rows and a custom

  • 0

we have a table in our page, with a few rows and a custom toggle button at the end.
the table is loaded via html in the page, not via json.

now, the togglebutton at the end posts to a service and sets the follow state of that record in the database.

however, it should also make an update to another cell in that row.
however i’m sure i should not do this via jquery manually but via datatables?

$('#tblFollow').dataTable({
    sDom: "t",
    aoColumns: [
      null,
      null,
      null,
      { bSortable: false }
    ]
});

$('#tblFollow').on('click', 'a.follow', function(e){
    $(this).toggleClass('active');

    // updating column 'following' here... 
    // but this only changes visually, and not the inner datatables data used for sorting
    var followingCell = $(this).parents('td').prev();
    var txt = followingCell.text() == "1" ? "0" : "1";
    followingCell.text(txt);

    return false;
});

manual example:
now i have an example, where i change the fields manually, but that’s only visual, the datatable still uses its inner data for sorting. So i’m looking for a way to do it better

  • 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-15T14:04:22+00:00Added an answer on June 15, 2026 at 2:04 pm

    Here is a possible solution:

    In addition to your code you should update the datatables data as following

    var rowIndex = table.fnGetPosition( $(this).closest('tr')[0] );
    var aData = table.fnGetData( rowIndex  );
    aData[2] = txt; //third column
    

    Here the jsfiddle

    And even better solution would be to use fnUpdate to update the data and display in the same time

    Here the jsfiddle

    // update column following here... 
    var followingCell = $(this).parents('td').prev();
    var txt = followingCell.text() == "1" ? "0" : "1";
    
    var rowIndex = table.fnGetPosition( $(this).closest('tr')[0] );
    table.fnUpdate( txt, rowIndex , 2);
    

    Also instead of us

    var followingCell = $(this).parents('td').prev();
    var txt = followingCell.text() == "1" ? "0" : "1";
    

    use

    var aData = table.fnGetData( rowIndex  );
    aData[2] //use it to check if the value is 0 or 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ColdFusion page with a styled HTML table in it. What I
We have an issue on our page whereby the first time a button posts
We've encountered the following situation in our database. We have table 'A' and table
We have a table that is used for assessment-values in our tool where each
I have a table containing data about some users. Many of them use our
In iOS apps, we have to register nib files with our table view before
I have table with around 70 000 rows. There is 6000 rows that i
I have table in which I am inserting rows for employee but next time
I have a table full of band listings for our Musician Finder program. We
We have the following table: CREATE TABLE [dbo].[CampaignCustomer]( [ID] [int] IDENTITY(1,1) NOT NULL, [CampaignID]

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.