Hey there, Awesome Customers!

Just a heads up: We'll be taking a breather to celebrate International Workers' Day (May 1st and 2nd - Wednesday and Thursday) and Orthodox Easter from Good Friday (May 3rd) through Easter Monday (May 6th). So, from May 1st to May 6th, our team will be off enjoying some well-deserved downtime.

During this time, our customer support will be running on a smaller crew, but don't worry! We'll still be around to help with any urgent matters, though it might take us a bit longer than usual to get back to you.

We'll be back in action at full throttle on May 7th (Tuesday), ready to tackle your questions and requests with gusto!

In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find loads of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel). These gems might just have the answers you're looking for while we're kicking back.

Thanks a bunch for your understanding and support!

Catch you on the flip side!

Warm regards,

TMS

Okay
  Public Ticket #2557289
Changing Default Rows Per Page
Closed

Comments

  • David started the conversation

    I'd like to change the default rows per page to 1000 and remove the All option.  How would I do this?

  •  2,498
    Aleksandar replied

    Hello David

    Thank you for your purchase.

    You can't use this option out-of-the-box, but there's a way to do it.

    You need to open this file: ../wp-content/plugins/wpdatatables/templates/admin/table-settings/table_settings_block.inc.php and around line 335 you'll see this:

    <select class="form-control selectpicker" id="wdt-rows-per-page">
       <option value="1">1</option>
       <option value="5">5</option>
       <option value="10">10</option>
       <option value="25">25</option>
       <option value="50">50</option>
       <option value="100">100</option>
       <option value="-1"><?php _e('All', 'wpdatatables'); ?></option>
    </select>

    You can replace the last option (All) with the 1000 option, like this:

    <select class="form-control selectpicker" id="wdt-rows-per-page">
       <option value="1">1</option>
       <option value="5">5</option>
       <option value="10">10</option>
       <option value="25">25</option>
       <option value="50">50</option>
       <option value="100">100</option>
       <option value="1000">1000</option>
    </select>
    

     And you'll have that option in the "Display" tab above the table:

    7120173477.png

    Then, open ../wp-content/plugins/wpdatatables/source/class.wpdatatable.php and around line 3207, and replace "All" with 1000, so it looks like this:

    $obj->dataTableParams->aLengthMenu = json_decode('[[1,5,10,25,50,100,1000],[1,5,10,25,50,100,1000]]');

    And the last thing to do is to go to line 499 of the same file, and modify it so it looks like this:

    public function setDisplayLength($length) {
            if (!in_array($length, array(1, 5, 10, 12, 20, 25, 30, 50, 52, 100, 200, 1000))) {
                return false;
            }
    

    So, again, replace -1 with 1000.

    You may also want to add the value in ../wp-content/plugins/wpdatatables/templates/admin/table-settings/column_settings_panel.inc.php around line 570, if you wish to add that value to possible column options (if you have a select-box filter, or selectbox editor input type, this would be the number of values displayed in those drop-downs).

    Please make sure to delete cache in your browser after you apply the changes.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • David replied

    That worked perfectly.  Thank you.

  •  2,498
    Aleksandar replied

    You're welcome, David

    Glad I could be of service.

    If you have any further questions or issues, please feel free to open a new ticket, and we'll gladly help.


    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Anto replied

    i want to remove/hide data view on default table. data will appear when performing a search in the search field. is it doable?

  •  2,498
    Aleksandar replied

    Hello Anto.

    If you acquire the Powerful Filters add-on, you will be able to hide the table before filtering is applied.

    Please check it out and let us know if you have any further questions.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Dalton replied

    Is there a way to achieve this without editing plugin files? Maybe through a hook or filter? Thanks!


    Update: I was able to find a solution using your 'wpdatatables_filter_table_description' filter. My only question now, is if there is a way to add an option to the admin edit table page as well, so that a default value of "2" rows can be set? Thanks!

  •  1,692
    Miloš replied

    Hi Dalton,

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -

    Aleksandar is on a Vacation, so I will take over this ticket.

    We will share both methods with you, at the moment these are the only ways we have to change the 'default number of rows' at the table back-end settings, as well as the front-end, which you already figured out, via a hook wpdatatables_filter_table_description.

    We don't have a built-in solution for this yet, but there is a workaround;

    First for the front-end number of rows, by adding a hook to your active Theme or child Theme's functions.php file.

    With this solution, it will not be affected by plugin updates

     since it would pull the function from the Theme itself.

    -

    For example, if you need the same options for all tables,

    add this hook: "wpdatatables_filter_table_description" to the active Theme's or child Theme's functions.php :

    add_filter( 'wpdatatables_filter_table_description', 'verse_show_entries', 10, 3 );
    function verse_show_entries( $object, $table_id, $wpDataTableOBJ ){  
      $object->dataTableParams->aLengthMenu = array(    
        array(             
                   10,     
                       25,    
                        50,     
                       75,       
                     100    
        ),      
      array(     
                   10,    
                    25,     
                   50,      
                  75,    
                    100  
          )  
      );  
      return $object;
    }
    

    ( This example removes the "ALL" option from the number of rows selection dropdown, but you can modify it to change/add options you need)

    Or, if you just need it for one specific table, you can pass table ID, as a parameter of the function, like this :

    add_filter( 'wpdatatables_filter_table_description', 'verse_show_entries', 10, 3 );
    function verse_show_entries( $object, $table_id, $wpDataTableOBJ ){
        if ($table_id == 1){
           $object->dataTableParams->aLengthMenu = array(
               array(
                   10,
                   25,
                   50,
                   75,
                   100
               ),
               array(
                   10,
                   25,
                   50,
                   75,
                   100
               )
           );
        }
        return $object;
    }

    ( On that example, the table ID is 1,  but you can set your table's ID)

    -

    Alternatively, if you wish to select multiple specific tables that should have this, you can add multiple table ID's, for example :

    add_filter( 'wpdatatables_filter_table_description', 'verse_show_entries', 10, 3 );
    function verse_show_entries( $object, $table_id, $wpDataTableOBJ ){
        if (in_array($table_id,[1,2,3,4,5,6])){
           $object->dataTableParams->aLengthMenu = array(
               array(
                   10,
                   25,
                   50,
                   75,
                   100
               ),
               array(
                   10,
                   25,
                   50,
                   75,
                   100
               )
           );
        }
        return $object;
    }
    

    Important to note :

    This hook is not going to change the options in the back-end table settings/Display settings, here the options will look the same :

    2730158179.png

    But it will directly override the settings on the table itself,  ( in both back and front-end),

    so if we check on the table's available options for number of rows,  it will then activate the hook's settings in the "Show Number of Entries" dropdown :

    9611596294.png

    Of course, that was an example where we removed the "ALL" rows option,

    but you can modify the hook, to change/add options you need.

    -

    Now, this other workaround is if you wish to change the available row options on the back-end of the table settings.

    You also can't use this option out-of-the-box, but there's a way to do it.

    You need to open this file:

     ../wp-content/plugins/wpdatatables/templates/admin/table-settings/table_settings_block.inc.php 

    and around line 367 you'll see this:

    <select class="form-control selectpicker" id="wdt-rows-per-page"> 
      <option value="1">1</option> 
      <option value="5">5</option> 
      <option value="10">10</option> 
      <option value="25">25</option> 
      <option value="50">50</option> 
      <option value="100">100</option>  
     <option value="-1"><?php _e('All', 'wpdatatables'); ?></option>
    </select>

    * When searching the code, it is best to search for a phrase using CTR+F,  since our devs might add new lines of code during Updates, then the exact line number changes,

    so i advise to search for "Rows per page selection" , and you will find the comment right above this code : 

    Then you can change the options as you need them,

     for this example, i reorder some values, i added option "15", and changed "All" to "1000".

                                       <option value="1">1</option>    
                                         <option value="5">5</option>   
                                            <option value="10">10</option> 
                                            <option value="15">15</option> 
                                             <option value="25">25</option>  
                                         <option value="50">50</option>    
                                             <option value="100">100</option> 
                                          <option value="1000">1000</option>
    
    6314974469.png

            Then you will see the options look like that, in the plugin, on table's Display tab :

    9398908774.png

    -

    Then, open ../wp-content/plugins/wpdatatables/source/class.wpdatatable.php 

    and around line 3737 ( or search for "aLengthMenu"), and replace the values as needed, in my example like this:

    $obj->dataTableParams->aLengthMenu = json_decode('[[1,5,10,15,25,50,100,1000],[1,5,10,15,25,50,100,1000]]');
    

    And the last thing to do is to go to line 544 of the same file ( or search for "setDisplayLength", and modify it so it looks like this:

    public function setDisplayLength($length) {   
         if (!in_array($length, array(1, 5, 10, 12, 15, 25, 30, 50, 100, 1000))) {  
              return false;
    

    So, again, change the values as needed.

    You may also want to add the value in

     ../wp-content/plugins/wpdatatables/templates/admin/table-settings/column_settings_panel.inc.php

     around line 570, 

    if you wish to add that value to possible column options (if you have a select-box filter, or selectbox editor input type, this would be the number of values displayed in those drop-downs).

    Please make sure to delete cache in your browser after you apply the changes.

     It works on my Test table, and Test site;   let me know if it works for yousmile.png

    7110967922.png

    Important to note : 

    During updates, this code will be overwritten, it will change to default code, so if you update the plugin, you have to repeat this process.

    We will work on adding a better solution as soon as possible, for the time being, it is like that.

    If you wish to affect the speed of development for these options,

    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.

    Let me know if that works for you.

    Thank you   smile.png       

           

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Dalton replied

    Hey Miloš,

    No worries! This should work fine for now. 

    Thanks!

  •   Miloš replied privately
  •  1
    Michael replied

    Hi Milos

    I followed your instruction, which works perfectly for my as well. I need 3 instead of 1 (3 medals).

    As a suggestion for future updates: I would be helpfull to have the definition of selectbox row elements decided by the admin somewhere in the admin panel.

    Best Regards Michael


  •  1
    Michael replied

    By the way, in the filter for more than 1 table a "closed braket" is missing.

  •  1,692
    Miloš replied

    Hi Michael,

    To begin, I want to extend my heartfelt apologies for the delayed reply, 

    which is due to an unexpectedly high volume of inquiries. 

    We truly value your patience during this period.

    -

    I am glad to see that the custom workaround has worked as intended for you as well, to edit the default rows per page options.


    When it comes to the future update suggestion, to add this somewhere as built-in option on Back-End to edit/change to custom default options;

     thank you, we appreciate it.

    You can affect this development speed by voting/ or adding it for voting if it does not already exist on our development suggestions Page.

    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.



    I just did not understand your last reply - you wrote that there is a closed bracket missing if you filter for more than one table;

    Would it be possible if you can open a new ticket and send us some screenshots/or a Video to elaborate a bit more on this issue - then we can try to reproduce it and see if it's a bug or just an error in the custom workaround?


    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  1
    Michael replied

    Hi Milos

    Thanks for your reply.

    Here is a screenshot about the missing braket.

    Best Regards Michael

    Attached files:  Screenshot 2024-02-29 104110.png

  •  1,692
    Miloš replied

    Hi Michael,

    My apologies once again for all the time between the replies.

    I can see exactly what you mean now, thank you for pointing this out - when i tested it in the Visual Studio Code Editor, it has highlighted that missing bracket with red color straight away;

    we have somehow missed it, but corrected it now for the future.smile.png


    1537848131.png
    5189712459.png

    Thanks again for pointing it out for us;

    and for the future improvement suggestion to add the native option.


    If anything else comes up, please don't hesitate to open new tickets.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables