Showing paging status with Paged Queries

Ok been studying this for 2 days now and for the life of me can NOT figure out how to do as you said

"if you are on the last page, and if yes, show the total number of records as:

3400- 3420 of 3420 Total Records. "

So can you please just provide the code that would do it that way I can learn.

Why do you right click the query?
Sorry I really canā€™t understand what are you doing. The tutorial I sent you shows exactly the logic of showing or hiding content depending on a dynamic value.

You could view the source code of the page I linked to, and copy the row with id: results_summary. This includes the code you want, and also includes various examples of hiding/showing content.

You would need to do a couple of find/replaces to match your data source and query, but after that it should work. Then, by selecting the various elements, you can see how you could have selected those options using the UI. Eg if you click on the binding for total records, you will see:

image

In some cases (like this one), I prefer to edit the code directly, but you can do it however you want; either way it will appear like this in the UI (with some exceptions, which donā€™t apply here).

Tom

I did as you suggested prior to posting the last time and here is what the code looks like

records found: {{paging.data.query1.total}} (showing {{paging.data.query1.offset + 1}} to

                        {{paging.data.query1.offset + (paging.data.query1.page.current != paging.data.query1.page.total?paging.data.query1.limit:(paging.data.query1.total % query.offset))}})</span></p>

No matter what I try the NaN still shows

26

records found: {{paging.data.query1.total}} (showing {{paging.data.query1.offset + 1}} to {{paging.data.query1.offset + (paging.data.query1.page.current != paging.data.query1.page.total?paging.data.query1.limit:(paging.data.query1.total % query.offset))}})

I tried what you had copied, and it seems to work. Interestingly - and this might be a clue as to the problem - you left out the first part of my code, which hides the bracketed part if limit >= total. If you search for one record (eg search for a stock number), you will see this (this is your version* below my version):

image

I think this is because 1 mod 0 = NaN (not a number); the offset will be 0 in this case. Itā€™s a sort of error which I hadnā€™t noticed as I wasnā€™t displaying it in this case (though I donā€™t know if it matters). However, it doesnā€™t explain why youā€™re seeing it where the offset is not 0.

*Iā€™m not sure if this is exactly your version - it may that you just didnā€™t paste all of the code.

Tom can you post the entire code for me again - thanks

Then can someone provide the steps to do that - something this simple should not take 3 days to accomplish. I would appreciate the actual code that will accomplish this instead for just directing me to another instructional page because obviously I donā€™t understand what needs to be done.

Hi Mike, just curious why you need to show record numbers as opposed to page numbers?

Itā€™s built into Wappler with no code editing required. Can be done in two minutes. You can still easily display total records as well.

Again, Iā€™m just curious - not saying you are wrong. :beer:

2 Likes

I* need it to show the number being viewed on the page i.e. 1-25 of 3,420. Right now I can get it to show the right number except on the last page where its shows like this 3401 - NaN of 3420 Total Records. I want it to show like this instead.

3401 - 3420 of 3420 Total Records

why - because my clients like it that way and Iā€™m trying to change the page coding from kollections based to Wappler keeping what was displayed the same over the last 13 years.

Ok Mike,
Hereā€™s the code you need, but try not to always copy paste code to achieve what you need in Wappler. I wanted to avoid providing the code, so that you can do it yourself. This way you will never understand how to use it, and whatā€™s the logic behind what you are doing.

Records {{paging.data.query1.offset+1}} - {{paging.data.query1.page.current == paging.data.query1.page.total ? (paging.data.query1.total) : (paging.data.query1.offset+paging.data.query1.limit)}} 

Please, in the future follow the tutorials, so you can understand how the things work and not blindly copy/paste code around your pages.

2 Likes

Believe it or not showing the code is more helpful than spending 5-7 days trying to understand this and getting frustrated to the point of giving up entirely. Which has happened on many occasions over the last 6-7 years.

Anyways thank you for this I added some code to complete it and although your code helps itsā€™s not doing exactly right on the last page

Here are the results

Records here 3401 - of 3420 Total Records

and I was trying to get it to look like this

Records here 3401 - 3420 of 3420 Total Records

how would I get the 3420 to show up ?

Does js not have the ability to display based on if - then or else like php can ?

Records {{paging.data.query1.offset+1}} - {{paging.data.query1.page.current == paging.data.query1.page.total ? (paging.data.query1.total) : (paging.data.query1.offset+paging.data.query1.limit)}} of {{paging.data.query1.total}} Total Records

Just add the total returned by the paged query.

And asking me this question just proves, that when you donā€™t try to understand how the things work then for every little change you will need someone to edit the code for you and send it back to you.

Well, the ternary operator in my example does exactly this.

First of all I donā€™t have to prove anything to you and I have tried to use your stuff for years, the biggest stumbling block has been you but this time I decided I needed to push through and stay with it longer. If that means asking for code then I will if you donā€™t want to provide any then that will prove to me things as well. Wappler is a completely new workflow for many people to learn and is completely different from php that most of us have used for years.

Instead of being pissy all the time why donā€™t your realize that not everyone is an expert or has your level of knowledge. If thats too hard to do then I recommend you no longer do technical customer support.

Mike, not sure i understand what exactly are you trying to say, but in my experience at DMXzone / Wappler for the past 11 years, itā€™s always the people who refuse/donā€™t want/donā€™t have time/(put other excuses here) to follow the tutorials and manuals are the ones who always have troubles.

I never said you must be an expert, or have my/teamā€™s level of knowledge.

And that is actually exactly what i am saying - when a person is not an expert - giving them a piece of code will make the things harder and harder for them. Copying random code from page to page, will only lead to more and more troubles in the future and will only make the whole process of using Wappler look harder than it is.
If you follow the docs, everything will be much easier once you get familiar with the product.

Anyway, hereā€™s the code you need and i hope youā€™re happy with it:

Records {{paging.data.query1.offset+1}} - {{paging.data.query1.page.current == paging.data.query1.page.total ? (paging.data.query1.total) : (paging.data.query1.offset+paging.data.query1.limit)}} of {{paging.data.query1.total}} Total Records

1 Like

Indeed the code does work thank you and it also helps me understand how the if then or else statements work within js now too.

Itā€™s the regular javascript ternary operator, which is available in the data formatter:

With Wappler you can use show/hide dynamic attributes to show/hide content as i already posted in the topic a few times.

Thanks this helps a lot