Hey everyone!

With the holiday season upon us, we want to share our upcoming working hours:

After that, we’ll return to our regular schedule and assist you as quickly as possible.

In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find tons of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel), which might just have the answers you need while we’re away.

Thanks a bunch for your understanding and support!

Warm regards and happy holidays!

TMS

Okay
  Public Ticket #3504991
Displaying top X from wpDataTable
Closed

Comments

  • Jereme Downs started the conversation

    I have a data table that displays some data on a page.  I also want to use a shortcode to display the top 5 records from this same data table.  Is this possible to do that just with using a shortcode (by using the data in this existing table) or do I have to build a second data table for this purpose?

  •  1,847
    Miloš replied

    Hi Jereme,

    Can you elaborate a bit more what is going to determine the top 5 records, would it perhaps filter by some Dates, or an ID field, or another way?

    I think you might use filtering through a Shortcode to load a different version of the same Table, but it depends exactly what you will use to 'narrow down' the selection of the top 5 rows.

    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 | 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,847
    Miloš replied

    Hi Jereme,

    Sorry, perhaps i over-complicated the use case, maybe you simply mean to show one version of the Table that displays "X" number of rows by default, but wish to try with a Shortcode to display a different number of first X number of rows somewhere else.

    -

    The only built-in option to set the default number of rows loaded per Table page is in the Table's Display Settings.

    But that will also allow users to change the Table Pages to reach the other rows.

    So i am still not sure of some details on the use-case, such as if you wish to do that by filtering/ and if you wish to allow users to reveal the other data or just to limit them to see the first 5 rows, etc.

    If you can elaborate a bit more with an example that would be the best, so we will advise.

    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 | 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

  • Jereme Downs replied

    I am looking to display the top 5 records based on a column that contains a dollar amount (float) - for example the top 5 users who have the highest sales.

    Or even be able to select and display specific top X values:

    The salesman with the most sales is [user] with $[sales_amount]

    The second highest salesman is [user] with $[sales_amount]

    This would be displayed as a combination of text and shortcode so I can add some context to the data values being displayed.  Even though this would likely come from a datatable, I'm looking to highlight these particular users outside of the datatable with some formatted text, etc wrapped around these values.  I hope that makes sense.

    Example:

    5155644679.png


  •  1,847
    Miloš replied

    Hi Jereme,

    Thank you for this clarification of the use-case, I can have a better understanding now.

    In a use-case like that, when you need to present that data outside of Tables, at the moment we do not have a solution to dynamically call 'top 3' of some values in the same Shortcode.

    You can only try our Single Cell Shortcode, that will allow you to pull only a specific cell from a DataTable.

    Please check more how it works here with our example.

    -

    If you use a server-side processing enabled table ( Like a Manual Table or SQL Table with enabled server-side option in the data Source settings),

    in that case you can only 'target' a specific unique Row ID.

    So let's say if Row ID 1 at the moment has a highest value, but later you add another value which will now sort the Table, so the table shows that new one on top row.

    But the unique Row ID for the new value will still be Row ID 2,  so if you placed the single cell shortcode as that row ID - it will still pull that initial cell.

    -

    The only workaround is if you use a non server side Tables which are linked from a file source like Excel, CSV, XML, Google Sheet, or PHP Array.

    In this case, for the "row ID" value you can target the current row index of a table.

    So, if you use sorting on a Table, then the sorted value should be pulled as the, for example, first row ( the top row).

    5326021299.png

    On the other hand, if you use SQL Based Tables ( Manual or SQL Query) , for them you have to 'target' a unique Row Value, so if the rows change 'position' by sorting it will not affect the cell pulled for that Shortcode.

    -

    That is how it currently works, if you have any suggestion how we could improve it,

    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.

    -

    So, to summarize, you will not be able to call multiple cells as "top 3 highest participants" for example, because our "Single cell Shortcode" Feature can only call one cell at a time.

    But if you can somehow try an alternate approach, to present the cells individually, you could try one section that says the title in the same way like "Top 3 Highest Participants" but then to do three separate Single Cell Shortcodes next to each other,  you can use any text to divide them like a "comma" perhaps, or anything like that;

    and just align three single cell shortcodes close to each other on that section.

    Then in the second Section named "Top 3 highest donors" you can do the same method, align three separate Single Cell Shortcodes close to each other, or use comma between each Shortcode, that could work.

    I hope that helps.

    Let me know if you have any additional 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 | 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,847
    Miloš replied

    Hi Jereme,

    My apologies, you actually did write that as an alternate method, i just did not fully understand at first, but exactly, something similar to :

    The salesman with the most sales is [user] with $[sales_amount]

    The second highest salesman is [user] with $[sales_amount]

    -

    So, that is the approach i was thinking of as well, you can definitely do that with our Single Cell Shortcode,

    it is just a question of server-side Table versus non-server Side, which will determine if you can call a "row index" from a sorted Table  versus a "unique Row identifier" which disregards sorting.

    I hope that helps.

    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 | 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

  • Jereme Downs replied

    Perfect, thank you.  It wasn't clear to me that I had to add an additional row ID field myself, I thought this was an internal ID based on the current row position of the query results.


    For anyone else looking to accomplish this, I added a row ID field to my SELECT statement using the ROW_NUMBER clause and ordered by the amount descending so I would get the proper row IDs in sequential order, starting with the record with the highest amount.

    ROW_NUMBER() OVER (ORDER BY SUM(`MyTable`.`donation_amount_total`) DESC) AS row_number


    I then had to go back to my datatable, make this new row_number field editable (Editing > Allow Editing = checked, ID column for editing = row_number), and specify the row_number value as the row_id in my shortcode.  This produces the three highest amounts:

    [wpdatatable_cell table_id="5" row_id="1" column_key="donation_amount_total"]
    [wpdatatable_cell table_id="5" row_id="2" column_key="donation_amount_total"]
    [wpdatatable_cell table_id="5" row_id="3" column_key="donation_amount_total"]


    Milos,

    For the amount column, I set '$' for the Cell content prefix.  The data preview on the data source page shows the $ in front of the amount values, but on the front end, where I'm using the shortcode, it does not - only the amount is shown without the $.  How do I get the prefix to show?  I don't want to add $ before the shortcode block because if the shortcode returns no value, then the page will display $ only, with no amount returned from the shortcode.

    Attached files:  1.png
      2.png

  •  1,847
    Miloš replied

    Hi Jereme,

    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.

    -

    Thank you very much for sharing these workarounds with us - We will certainly make Note of them, this will help future users who wish to achieve the same use-case, for both adding a row ID field to the SQL Query Table which will always be in sequential order, regardless of the unique Table Row to follow the current 'sorted order' in the Table;

    As well as taking advantage of that with our Single Cell Shortcode as you did.

    -

    2. When it comes to passing a prefix/ or suffix from the source Table to the Single Cell Shortcode, as far as I am aware, that is not possible at the moment, the Single Cell Shortcode only takes the value from the cell itself, while the prefix only renders in the Table.


    But this is a great idea for future development, i hope our devs should be able to add an option to pull the prefix in the Single Cell Shortcode.

    You can add the suggestion and we will do our best.

    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.

    -

    That being said, we will work on this in the meantime, to see if there is any custom workaround you might try to achieve this, if our developers advise on any possible way, we will make sure to report back to share it with you.

    Thanks again.


    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 | 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,847
    Miloš replied

    Hi Jereme,

    I got advised by our Developers, we have confirmation on what are the current possibilities, so i just wanted to make a small follow-up.

    1. One way you could approach this is to change this Column's Data Type from Numeric to a String Column.

    I forgot to mention that the last time, sorry about that.

    This way you will be able to input the currency sign/ or any other symbol inside the cell directly, and that way the '$' will be pulled as part of the cell value in the Single Cell Shortcode.

    For example, like :

    8609918779.png

    7425763179.png

    The downside of that is, for example if you need to have some calculations done or to use that Column in a Formula, you won't be able to do that with a non-numeric Column Type.


    2. The only other way is to input a sign as part of your text/content on the WP page , before the Single Cell Shortcode, but i know you tried that already and i understand that won't work in the use-case/scenario when it might return a blank value to avoid having only the currency symbol without the actual cell value.


    3. But at the moment it is definitely not possible in any way, we don't have a workaround to pull the cell prefix with the Single Cell Shortcode/  The prefix can only render when it is inside the Table itself.

    You can leave a development suggestion as mentioned, and we will do our best to add it in the future.


    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 | 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