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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:20:48+00:00 2026-05-28T13:20:48+00:00

I have a select menu with two options All and test…..when I select All

  • 0

I have a select menu with two options “All” and “test”…..when I select “All” a datatable with 15 columns is shown and when “test” is selected, another datatable with 5 columns is selected….

When there are less than or equal to 5 items, the pagination should be disabled…

This is what I’ve done so far,

created the 2 datatables as mentioned,

function All(){

$('#All').dataTable({
    "iDisplayLength": 5,
    "sPaginationType": "four_button",
    "bJQueryUI": true,
    "bRetrieve": true,
    "bAutoWidth": false,
    "fnDrawCallback": function() {
            if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1)  {
                    $('.dataTables_paginate').css("display", "block");
            } else {
                    $('.dataTables_paginate').hide();
            }
        }
});
}

function Test(){

$('#Test').dataTable({
    "iDisplayLength": 5,
    "sPaginationType": "four_button",
    "bJQueryUI": true,
    "bRetrieve": true,
    "bAutoWidth": false,
    "fnDrawCallback": function() {
            if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1)  {
                    $('.dataTables_paginate').css("display", "block");
            } else {
                    $('.dataTables_paginate').hide();
            }
        }
});
}

$(document).ready(function(){

$('#List').val('All');
All();
$('#test').hide();

$("#List").change(function(){

if(this.value == 'All'){

        All();
        $('#All').show();
        $('#Test_wrapper').hide();
}
else if (this.value == 'Test'){
        Test();
        $('#Test').show();
        $('#All_wrapper').hide();
}
});
});

As you can see, I’m checking for the pagination in the “fnDrawCallBack” function……
The page loads find when called upon initially…..but when I select All after selecting test, the pagination disappears, understandably……

is there any work around for this? Any help is appreciated….

Thanks

  • 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-28T13:20:49+00:00Added an answer on May 28, 2026 at 1:20 pm

    Never mind, found a solution to implement this……

    In documennt.ready function, put something like this inside the if condition for each table……..

    $("#productsList").change(function(){
    
            if(this.value == 'All'){
                All();
                all.fnPageChange( 'first' );
                $('#All').show();
                $('#Test').hide();
                if (Math.ceil((all.fnSettings().fnRecordsDisplay()) / all.fnSettings()._iDisplayLength) > 1)  {
                        $('.dataTables_paginate').css("display", "block");
                    } else {
                            $('.dataTables_paginate').hide();
                    }
    

    Also, you do a similar if loop when “test” is selected from drop down…

    The other way that I tried doing it, (found the above solution more feasible, that’s it)…

    Try to identify if the child node is active using jQuery….by putting this inside your if condition of the documenty.ready function when the value changes,

    if($('#Test_wrapper #paginate_next').hasClass('paginate_enabled_next') || $('#Test_wrapper #paginate_previous').hasClass('paginate_enabled_next')){
                    $('#Test_wrapper .dataTables_paginate').css("display", "block");
                } else {
                    $('#Test_wrapper .dataTables_paginate').hide();
                }
    

    Note: The above mentioned method’s only hides your pagination…..

    I’ve tried, destroying my old table and recreating it but that was showing a javascript error, didn’t have time to look into it….shall do when I’ve time 🙂

    Please let me know, if there is a better solution to this……

    Cheers and thanks for taking time to read this off 🙂

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

Sidebar

Related Questions

I have a drop down menu, with two options: <select name="chs" value="" id =
Say I have a form_for with a select menu to assign a User on
I have a little dropdown menu similar <select> , which contolled from external js-function.
I have a form in which a user can select multiple options in a
I have two .php files which show all contacts in a database, then allows
I have the following drop down menu: <select id=target> <option value=0>Zero ($123.45)</option> <option value=1>One
I have a model of objects in a dropdown menu: <select id=group_select name=group_select> <option
Here have two list field menu. First brand second item I want if we
I have two select lists which are being styled using the jQuery UI Selectmenu
Say I have: <ul class=menu> <li>One</li> <ul class=submenu> <li>Apple</li> <li>Orange</li> </ul> <li>Two</li> <ul class=submenu>

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.