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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:35:19+00:00 2026-05-23T07:35:19+00:00

I am using DataTables plugin to fetch and paginate my table use ajax calls.

  • 0

I am using DataTables plugin to fetch and paginate my table use ajax calls.
My requirement is that I need to sort only the ones that I have fetched i.e. client side sorting while Server side fetching.

To achieve this i am using tablesorter along with the dataTables plugin. My code looks something like this –

$("#ProposalSearchResults").html('<table cellpadding="0" id="proposalsTable" cellspacing="0" border="1 px" class="dataTable tablesorter">');
        $("#proposalsTable").tablesorter();
        $("#proposalsTable").dataTable({
            "bPaginate": true,
            "bJQueryUI": true,
            "bLengthChange": false,
            "bFilter": false,
            "bSort": false,
            "bInfo": true,
            "bAutoWidth": false,
            "bServerSide":true,
            "iDisplayLength": 10,
            "bProcessing": true,
            "sPaginationType": "full_numbers",
            "aoColumns": [
                            {"sTitle" : "Proposal Id"},
                            {"sTitle" : "Release Candidate Id"},
                            {"sTitle" : "Proposal Description"},
                            {"sTitle" : "Application"},
                            {"sTitle" : "Requester"},
                            {"sTitle" : "Proposal Status"},
                            {"sTitle" : "Proposal Creation Date", "sType": "full_date" },
                            {"sTitle" : "Proposal Planned Deployment Date", "sType": "full_date" },
                            {"sTitle" : "Action"}
                        ],
            "sAjaxSource": "/searchProposals",
            "fnServerData": function(sSource, aoData, fnCallback){
                aoData.push({"name" : "searchCriteria", "value" : JSON.stringify(proposalSearchCriteria)});

                $.ajax({
                    "dataType": "json",
                    "type" : "GET",
                    "url" : sSource,
                    "data" : aoData,
                    "success" : function (serviceOutput){
                        fnCallback(serviceOutput.ret);
                        $("#proposalsTable").trigger("update");
                    }
                });
           }
        });

Now the problem here is that because in the beginning, the thead and tbody of the table are not formed, the call to tablesorter() returns and client side sorting is not achieved.
While, when I do the same with creating thead and tbody first and then populating it through ajax, it works.
I have not been able to decode the code of dataTables so dont know which method is actually drawing/writing these tbodies and thead in the table, which can be overriden to have this call to tablesorter in it too.

Can someone please help me out here.

  • 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-23T07:35:20+00:00Added an answer on May 23, 2026 at 7:35 am

    You should call $("#proposalsTable").tablesorter(); after the call to dataTables(). In this way datatables creates the <thead> and all <th> sections (all the proper markup and so on) on which you can attach tablesorter events.
    If you do as you did, there are no <th> to attach events to and so tablesorter() fails. Remember that you can attach events only to elements alredy existing in the DOM (ok, there are some ways to attach also to elements added after the DOM is ready like jQuery live() but i don’t think tablesorter uses them), in you case datatables creates the markup for the table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the DataTables plugin for jQuery and need to get one of
I have been using the DataTables plugin for jQuery (http://www.datatables.net) to search, sort and
I have started using the DataTables plugin (v1.6.2) for jQuery (v1.4.2), and I would
When adding a row dynamically using jQuery DataTables plugin , what do I do
I am trying to delete a row using the DataTables plugin. First I don't
I am using the jQuery DataTables plugin. I would like to move the search
I am using the datatables jquery plugin and want to sorty by dates. I
I'm using the DataTables jQuery plugin and am having issues with the First and
I am using the DataTables jQuery plugin. The way I want my tables to
I'm using the jQuery DataTables plugin, which is working really great so far. However

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.