Perhaps I'm missing something - but is there a simple way to display row numbers? I'm running an SQL query that pulls a list of sales by sales reps. Then it sums the sales by each rep and groups the result into a total sales column that is sorted by DESC. Thus creating a sales leaderboard.
But I can't find a way to add a row number (index) of the result so you see the place of the sales rep - i.e. 1st place, 2nd place, etc.
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.
-
Unfortunately, adding row numbers to tables is not possible with our built-in features.
The front-end (JS) part of wpDataTables plays a significant role in the plugin’s functionality. Generally, front-end rendering is done by the DataTables jQuery plugin
All wpDataTables existing on the page are reflected in the global JavaScript object called ‘wpDataTables‘. If you check this variable in the JS developer console you will see the wpDataTables as properties of this object.
-
I have a custom workaround with a bit of JS that you can try, though.
First you will add a first empty column at the beginning of the table and i will show you a JS script you can use, then it will always show fixed row numbers in this column , starting from 1 and so on.
-
This script will check if there is a table on the page, and if there is - it will add the row numbers, fixed from 1 > until the last row.
If you change the sorting, filtering, that first column will always have fixed numbers.
The front-end (JS) part of wpDataTables plays a significant role in the plugin’s functionality. Generally, front-end rendering is done by the DataTables jQuery plugin
All wpDataTables existing on the page are reflected in the global JavaScript object called ‘wpDataTables‘. If you check this variable in the JS developer console you will see the wpDataTables as properties of this object.
-
Here are the instructions to make this workaround.
First add one column in your file or data source at the start of the table (as first column),
Then we will use this JS code.
I added this in my plugin settings/Custom Js and CSS/Custom JS :
Thanks for this - I realized since I only need to display row numbers (not do anything with them) I just added the blank column and use the :before css selector to insert the numbers I needed. :-)
P.S. I added a feature request for a progress bar/thermometer display. Might be handy for some people!
Perhaps I'm missing something - but is there a simple way to display row numbers? I'm running an SQL query that pulls a list of sales by sales reps. Then it sums the sales by each rep and groups the result into a total sales column that is sorted by DESC. Thus creating a sales leaderboard.
But I can't find a way to add a row number (index) of the result so you see the place of the sales rep - i.e. 1st place, 2nd place, etc.
Seems like this basic function is missing:
ROW_NUMBER() OVER(ORDER BY name) AS num_row
Hi ,Jay.
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.
-
Unfortunately, adding row numbers to tables is not possible with our built-in features.
The front-end (JS) part of wpDataTables plays a significant role in the plugin’s functionality. Generally, front-end rendering is done by the DataTables jQuery plugin
All wpDataTables existing on the page are reflected in the global JavaScript object called ‘wpDataTables‘. If you check this variable in the JS developer console you will see the wpDataTables as properties of this object.
-
I have a custom workaround with a bit of JS that you can try, though.
First you will add a first empty column at the beginning of the table and i will show you a JS script you can use, then it will always show fixed row numbers in this column , starting from 1 and so on.
-
This script will check if there is a table on the page, and if there is - it will add the row numbers, fixed from 1 > until the last row.
If you change the sorting, filtering, that first column will always have fixed numbers.
The front-end (JS) part of wpDataTables plays a significant role in the plugin’s functionality. Generally, front-end rendering is done by the DataTables jQuery plugin
All wpDataTables existing on the page are reflected in the global JavaScript object called ‘wpDataTables‘. If you check this variable in the JS developer console you will see the wpDataTables as properties of this object.
-
Here are the instructions to make this workaround.
First add one column in your file or data source at the start of the table (as first column),
Then we will use this JS code.
I added this in my plugin settings/Custom Js and CSS/Custom JS :
You can try either to add it the same way in the plugin's Custom JS ,
or if you wish to add it directly to WP page(s) , add it wrapped in <script></script> tags as Custom HTML in your page builder.
Let me know if that helps, it should work.
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 for this - I realized since I only need to display row numbers (not do anything with them) I just added the blank column and use the :before css selector to insert the numbers I needed. :-)
P.S. I added a feature request for a progress bar/thermometer display. Might be handy for some people!