I would like the users to be able to select the number of rows they can display on the page. But I don't want to give them the option of "All". Just 10, 25, 50, and the maximum is 100.
This hook is not going to change the options in the back-end table settings/Display settings, here the options will look the same :
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 :
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.
* 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".
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 you
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,
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.
Hello,
I would like the users to be able to select the number of rows they can display on the page. But I don't want to give them the option of "All". Just 10, 25, 50, and the maximum is 100.
How can this be done?
Thank you
Hey, Syed .
Sorry for the delay, we had a weekend break.
-
We don't have a built-in solution for this yet, but there is a workaround
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 :
( 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 :
( 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 :
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 :
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 :
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:
* 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".
Then you will see the options look like that, in the plugin, on table's Display tab :
-
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:
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:
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 you
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
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
Thank you! This is very helpful
Hi, Syed
Apology for this late reply, we had our National Holiday.
You're very welcome. I am happy to help.
As you know, please don't hesitate to reach out to us with new tickets whenever you have any questions.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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