SELECT view_talent_income.`post_date`, view_talent_income.`month`, view_talent_income.`year`, view_talent_income.`post_author`, view_talent_income.`amount_owed`, view_talent_income.`amount_paid` FROM view_talent_income WHERE post_author = %CURRENT_USER_ID%
which queries a view and limits the results to the current user.
While it works fine there are a couple of things I would like to achieve that I do not see a way to do through the UI. Answers that require coding are fine.
a) Is there a way to dynamically set an initial value for the year filter? I want to be able to set it to the largest value in the list of values for the current user
b) Is there a way to set "Row per page", the built in choices jump from 10 to 25 and I really want to set it 12 (1 year), particularly if there is no way to do (a)
1. In regards to setting up an initial value for the Year Filter, i am not sure if i fully understood that use-case.
You said "set it to the largest value in the list of values for the current user".
We have ways to predefine a filter for a column, but not to look up for all values and then for the plugin to pick the highest value possible of that column.
For example, we have these VAR dynamic placeholders ( %VAR1%, %VAR2%, %VAR3% and so on) –
these are the ‘variable’ placeholders. You can provide a default value here that will be used for table generation, and when a different one is not defined in the shortcode.
SELECT * FROM yourDatabaseTable
WHERE columnName = '%VAR1%'
%VAR1% can be defined in the Placeholders tab when you're creating a table,
or you can pass VAR1 value in the table's shortcode.
-
For example if i have this Master Manual Table,
and i want to make a dynamic SQL Table with VAR1 placeholder. ( Then later i can input different VAR1 in the table shortcode on different pages).
My example SQL Query for the table will be :
SELECT * FROM wp_wpdatatable_44
WHERE company = '%VAR1%'
First, just to initially generate an SQL table with the VAR1 ,
i will set the Cakewalk company name in the VAR1 , in table's Placeholders tab :
-
Then, for example, if i want to make a different page for another Company,
let's say "Adobe". Then i pass that value in the VAR1 of the table shortcode :
2.
Or, if you don't add the condition in an SQL query, you can add %VAR1% in column settings -> Filtering, under "Predefined filtering value".
Then, you can have different versions of the same table, with the VAR1 value passed in the shortcode,
let's say if we had a "Regions" column and we wish to filter a different region per each page.
If we want page 1 for example only filtered for "Region A" , you can set predefined filter to this column as %VAR1% (filter type has to be set as text) :
Then for a page where we need only Region 1 filtered, use shortcode [wpdatatable id=1 var1='Region A'] ,
page 2 for only "Region B", shortcode would be [wpdatatable id=1 var1='Region B'] and so on,
to apply the values defined in the shortcode to the filter.
( This filtering method can be used for any table type, besides Simple Tables)
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.
On the pagination, since I want it on the back end (I want it preset to 12) I will follow your instructions. It would be nice if there was filter for this.
As for the use of the place holder I looked at using "Predefined values" setting as shown in your video but run into a problem. If you look at v1.png this what I see initially. But as soon as I click on the text block, I see what is shown in v2.png. No matter what I type there nothing "sticks", In particular I tried 2023 and %VAR1% but neither work.
My sincerest apology again for the waiting time on the reply.
1. Yes, our developers will work to somehow add an option to choose a custom number of rows per default for pagination,
i can't say an ETA on it, though.
But you can make a suggestion for our devs on the Suggestions Page we sent in the previous reply and this way, as more users vote for it, our Planning Team will raise the priority compared to other requested features/improvements.
2. In regards to the filtering predefined Values that you're trying to set :
If i understood, when you try to set up some predefined filter values for the `year` column,
which is set to Date Column Type, and you try to search for a possible value - it does not work as expected?
I have reproduced this now on my own table,
for example if i set the column to a Date type, and try to use a "selectbox" filter, it can work in a table,
but for a Date Column it is not possible to set up a selectbox filter with predefined values.
If we change the Column type to a String Column, in the Data Tab we will be allowed to set up manually predefined values :
While if we use a Date Column, we don't have the "Possible values for Column" section on the right side:
I think it is not a bug, but we will double-check this with our QA Team just to be sure.
So it seems logical that what we tried earlier won't work, as a "selectbox with predefined values";
But, for example if you try with a "Text Filter", then you will be able to use VAR1 Placeholder for the Date Column, or some specific date value.
And then you will be able to use the VAR placeholder such as in the previously shared examples, that might be a workaround.
Let me know if that makes sense, and i will just double-check with our QA if this is the current logic of how our Date columns work, or if it might be a bug.
Sorry to disappoint you, but it is not possible to have the same way of predefining values for Dates,
as we can do for String type data.
For Strings, you can set up predefined values,
but for the Date type, the database reads it in a different way - it is just possible as a "Date Range" filter.
-
The only workaround you can do, if you need to set up some predefined filtering value for date values,
is to convert these values to String Data type.
But we advise caution when doing that, just to be safe, because for example if you have a Manual Table and change the Date Type of this column from Date to String, it can mess up the data of that column in the database table itself.
So we suggest first to make a duplicate of this table, you can do that from the wpDataTables list in the back-end,
then you can try to make an export of the table, for example as Excel.
Then in this Excel file, for the Date Column(s), make sure to format them as "text",
then you can re-import the data to replace the data source for a Manual Table,
and our plugin will create /save that Column as String, so with String Columns you will be able to predefine values as needed for selectbox/multiselectbox/checkbox filters.
-
Let me know if that helps, and if anything is not clear.
The year is already a string (in mysql it is varchar(4))
Original data comes from posts and postmeta.
Table gets its data from a view where the year is a string.
What I want to achieve is a filter with a type of select that allows the user to select the year (this part works) andI want to be able to set the initial year set but the fact I can not simple enter a value prevents me from doing this.
If I change the filter type to text I can set the initial value to %VAR1% and this works but now the user needs to know what a valid year is.
It would be nice that when the filter type is 'select' I could simple type the initial value in the same way as when the filter type is 'text'.
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.
-
Yes, in regards to using a %VAR1% , it can only be used on a Text type Filter in a Column.
But if you need to just input a simple value as the initial value - predefined for a Selectbox Filter,
you can set possible values for filtering in the Column Settings, then go to Data Tab.
Here is my example, if i got some Dates in this Table and i want to predefine available selectbox Filtering value for specific Years only.
First i change the Column Type to String, then i will show some screenshots :
Change the Possible Values for Column from "Read from table on Page Load" to "Define values list",
then we manually predefine the values :
Now i can go back in the column Filtering tab and predefine a value.
You actually don't need to "Define values list",
the same principle can be used if you just let the table load all available values,
and you can still go in the Filtering Tab and choose one of the values as a predefined.
But i guess this is useful if you just want to "isolate" the year from the full date value that is set as a String.
Thanks, while I like the table plugin I find it does not meet my current needs. The tables are annual reports and I need to be able to dynamically build a filter with the years appropriate to the report AND set the default year to the last valid year.
Also having to change the plugins code to set custom values on the back end for max rows to display is unappealing
Instead I have decided to use jQuery TableData and custom code.
I have a table with this data source,
SELECT view_talent_income.`post_date`,
view_talent_income.`month`,
view_talent_income.`year`,
view_talent_income.`post_author`,
view_talent_income.`amount_owed`,
view_talent_income.`amount_paid`
FROM view_talent_income
WHERE post_author = %CURRENT_USER_ID%
which queries a view and limits the results to the current user.
While it works fine there are a couple of things I would like to achieve that I do not see a way to do through the UI. Answers that require coding are fine.
a) Is there a way to dynamically set an initial value for the year filter? I want to be able to set it to the largest value in the list of values for the current user
b) Is there a way to set "Row per page", the built in choices jump from 10 to 25 and I really want to set it 12 (1 year), particularly if there is no way to do (a)
Thanks
Hi, Steve.
Sorry for a late reply.
1. In regards to setting up an initial value for the Year Filter, i am not sure if i fully understood that use-case.
You said "set it to the largest value in the list of values for the current user".
We have ways to predefine a filter for a column, but not to look up for all values and then for the plugin to pick the highest value possible of that column.
For example, we have these VAR dynamic placeholders ( %VAR1%, %VAR2%, %VAR3% and so on) –
these are the ‘variable’ placeholders. You can provide a default value here that will be used for table generation, and when a different one is not defined in the shortcode.
You can see more about our Placeholders here.
But i will also show some basic examples that we have.
There can be different ways to pre-filter tables in our plugin :
If you wish to try Pre-filtering tables through URL, please check out this page with examples.
-
You can also use placeholders for table generation.
1. For example, if you have a MySQL query-based table, you can use this query:
%VAR1% can be defined in the Placeholders tab when you're creating a table,
or you can pass VAR1 value in the table's shortcode.
-
For example if i have this Master Manual Table,
and i want to make a dynamic SQL Table with VAR1 placeholder. ( Then later i can input different VAR1 in the table shortcode on different pages).
My example SQL Query for the table will be :
First, just to initially generate an SQL table with the VAR1 ,
i will set the Cakewalk company name in the VAR1 , in table's Placeholders tab :
-
Then, for example, if i want to make a different page for another Company,
let's say "Adobe". Then i pass that value in the VAR1 of the table shortcode :
2.
Or, if you don't add the condition in an SQL query, you can add %VAR1% in column settings -> Filtering, under "Predefined filtering value".
Then, you can have different versions of the same table, with the VAR1 value passed in the shortcode,
let's say if we had a "Regions" column and we wish to filter a different region per each page.
If we want page 1 for example only filtered for "Region A" , you can set predefined filter to this column as %VAR1% (filter type has to be set as text) :
Then for a page where we need only Region 1 filtered, use shortcode [wpdatatable id=1 var1='Region A'] ,
page 2 for only "Region B", shortcode would be [wpdatatable id=1 var1='Region B'] and so on,
to apply the values defined in the shortcode to the filter.
( This filtering method can be used for any table type, besides Simple Tables)
I also made a short basic video example - please check it out here, if you wish.
-
My apology if that was too much information, but i just wanted to share these examples we have, i hope it helps.
Let me know if i misunderstood what is needed, that are our current capabilities when it comes to predefined filtering.
2. Is there a way to set "Row per page".
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:
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
Thanks
On the pagination, since I want it on the back end (I want it preset to 12) I will follow your instructions. It would be nice if there was filter for this.
As for the use of the place holder I looked at using "Predefined values" setting as shown in your video but run into a problem. If you look at v1.png this what I see initially. But as soon as I click on the text block, I see what is shown in v2.png. No matter what I type there nothing "sticks", In particular I tried 2023 and %VAR1% but neither work.
Attached files: v2.png
v1.png
Hi, Steve.
My sincerest apology again for the waiting time on the reply.
1. Yes, our developers will work to somehow add an option to choose a custom number of rows per default for pagination,
i can't say an ETA on it, though.
But you can make a suggestion for our devs on the Suggestions Page we sent in the previous reply and this way, as more users vote for it, our Planning Team will raise the priority compared to other requested features/improvements.
2. In regards to the filtering predefined Values that you're trying to set :
If i understood, when you try to set up some predefined filter values for the `year` column,
which is set to Date Column Type, and you try to search for a possible value - it does not work as expected?
I have reproduced this now on my own table,
for example if i set the column to a Date type, and try to use a "selectbox" filter, it can work in a table,
but for a Date Column it is not possible to set up a selectbox filter with predefined values.
If we change the Column type to a String Column, in the Data Tab we will be allowed to set up manually predefined values :
While if we use a Date Column, we don't have the "Possible values for Column" section on the right side:
I think it is not a bug, but we will double-check this with our QA Team just to be sure.
The way i see it, if we check this Documentation about our Date Columns, it states that applicable Filter Type is "date Range".
So it seems logical that what we tried earlier won't work, as a "selectbox with predefined values";
But, for example if you try with a "Text Filter", then you will be able to use VAR1 Placeholder for the Date Column, or some specific date value.
And then you will be able to use the VAR placeholder such as in the previously shared examples, that might be a workaround.
Let me know if that makes sense, and i will just double-check with our QA if this is the current logic of how our Date columns work, or if it might be a bug.
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
Hi, Steve.
We have confirmation on this.
Sorry to disappoint you, but it is not possible to have the same way of predefining values for Dates,
as we can do for String type data.
For Strings, you can set up predefined values,
but for the Date type, the database reads it in a different way - it is just possible as a "Date Range" filter.
-
The only workaround you can do, if you need to set up some predefined filtering value for date values,
is to convert these values to String Data type.
But we advise caution when doing that, just to be safe, because for example if you have a Manual Table and change the Date Type of this column from Date to String, it can mess up the data of that column in the database table itself.
So we suggest first to make a duplicate of this table, you can do that from the wpDataTables list in the back-end,
then you can try to make an export of the table, for example as Excel.
Then in this Excel file, for the Date Column(s), make sure to format them as "text",
then you can re-import the data to replace the data source for a Manual Table,
and our plugin will create /save that Column as String, so with String Columns you will be able to predefine values as needed for selectbox/multiselectbox/checkbox filters.
-
Let me know if that helps, and if anything is not clear.
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
The year is already a string (in mysql it is varchar(4))
Original data comes from posts and postmeta.
Table gets its data from a view where the year is a string.
What I want to achieve is a filter with a type of select that allows the user to select the year (this part works) and I want to be able to set the initial year set but the fact I can not simple enter a value prevents me from doing this.
If I change the filter type to text I can set the initial value to %VAR1% and this works but now the user needs to know what a valid year is.
It would be nice that when the filter type is 'select' I could simple type the initial value in the same way as when the filter type is 'text'.
Thanks
Hi, Steve.
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.
-
Yes, in regards to using a %VAR1% , it can only be used on a Text type Filter in a Column.
But if you need to just input a simple value as the initial value - predefined for a Selectbox Filter,
you can set possible values for filtering in the Column Settings, then go to Data Tab.
Here is my example, if i got some Dates in this Table and i want to predefine available selectbox Filtering value for specific Years only.
First i change the Column Type to String, then i will show some screenshots :
Change the Possible Values for Column from "Read from table on Page Load" to "Define values list",
then we manually predefine the values :
Now i can go back in the column Filtering tab and predefine a value.
You actually don't need to "Define values list",
the same principle can be used if you just let the table load all available values,
and you can still go in the Filtering Tab and choose one of the values as a predefined.
But i guess this is useful if you just want to "isolate" the year from the full date value that is set as a String.
Let me know if that helps?
Thanks.
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
Thanks, while I like the table plugin I find it does not meet my current needs. The tables are annual reports and I need to be able to dynamically build a filter with the years appropriate to the report AND set the default year to the last valid year.
Also having to change the plugins code to set custom values on the back end for max rows to display is unappealing
Instead I have decided to use jQuery TableData and custom code.
Again, Thanks.
Hi, Steve.
My apologies once again for a late reply.
I can completely understand what you mean.
We will do our best to make improvements on these points in the future,
for the time being it is as you described, these are the limitations we currently have.
Thank you for this feedback, we are passing it to our developers, they will do their best to add improvements as soon as possible,
we hope we might see you as our premium user in the future again.
We wish you all the best.
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