Page 1 of 1

Displaying Found Count (Like FMP)

PostPosted: Fri Dec 24, 2004 3:55 pm
by bcusick
Merry Christmas to the 1,000,000 FileMaker Developers who have asked, begged and cajoled for an easy way to show the record count in Servoy.

Code: Select all
var x = "Record " + currentcontroller.getSelectedIndex() + " of " + currentcontroller.getMaxRecordIndex()

x += " (" + databaseManager.getFoundSetCount(forms[currentcontroller.getName()].foundset) + " in foundset)"

globals.rec_display = x


I used globals.rec_display - but you can use any global you want. Make this code a global method and attach it to each form's "onShow" event. Also, make sure you call it after new record, delete record, show all records, duplicate record, omit record on EVERY form you use it on.

That means you'll need to hook up a method to all of the above commands (you can use a single global method to create records, delete records, etc using currentController) - as well as hook up a method for FIND on all your forms.

REMEMBER: Servoy isn't FileMaker! :D

ENJOY!

PostPosted: Fri Dec 24, 2004 4:07 pm
by grahamg
Hi Bob

Thanks for the Xmas present - don't think I would have worked that one out myself :D

Also Merry Xmas and Successful New Year to all the Servoy team. 2004 has been a great year and I have the feeling that 2005 will rock.

GrahamG

PostPosted: Fri Dec 24, 2004 4:14 pm
by bcusick
grahamg wrote:Thanks for the Xmas present - don't think I would have worked that one out myself :D


You're very welcome! I'm sure you would have - give yourself more credit! :D

grahamg wrote:Also Merry Xmas and Successful New Year to all the Servoy team. 2004 has been a great year and I have the feeling that 2005 will rock.


Thank YOU and all the other fantastic Servoy Developers that have helped to make this product as great as it is. I KNOW 2005 will ROCK!

Thanks for your continued support and enthusiasm.

Re: Displaying Found Count (Like FMP)

PostPosted: Thu Dec 29, 2005 6:04 am
by amcgilly
Rather than calling this code from all the places you mentioned (onNext, onPrev, onInsert, etc.) wouldn't it be easier to call it from the onRecordSelection event? That event signals that the user has changed from one record to another.

Also, a question about the code you provided:

Code: Select all
var x = "Record " + currentcontroller.getSelectedIndex() + " of " + currentcontroller.getMaxRecordIndex()

x += " (" + databaseManager.getFoundSetCount(forms[currentcontroller.getName()].foundset) + " in foundset)"

globals.rec_display = x



If the above code displayed, say, "5 of 500 (25,000 in foundset)" it would mean that I've got 500 records cached, I'm looking at the 5th record in that batch, and my most recent search really mapped to 25,000 records, right?

What happens when the user is looking at the 500th record and hits next record? What will that piece of code output then?

PostPosted: Thu Dec 29, 2005 12:45 pm
by patrick
What happens when the user is looking at the 500th record and hits next record? What will that piece of code output then?


It will output

Code: Select all
501 of 700 (25,000 in foundset)


Servoy always fetches 200 records. So actually, the 500 is unlikely. You will more likely see

Code: Select all
401 of 600 (25,000 in foundset)


currentcontroller.getMaxRecordIndex() will update itself when the 200 limit is reached. A common mistake is this

Code: Select all
var numOfRecords = foundset.getSize()
for (var i = 1, i <= numOfRecords, i++) {
... }


The variable numOfRecords will NOT be updated. So if you have a large foundset, numOfRecords will be set to 200 and your loop will stop at 200. If you do

Code: Select all
for (var i = 1, i <= foundset.getSize(), i++) {
... }


the loop will not stop at 200, because at 200 getSize() will be updated to 400 and so on...