Displaying Found Count (Like FMP)

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Displaying Found Count (Like FMP)

Postby bcusick » Fri Dec 24, 2004 3:55 pm

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!
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby grahamg » Fri Dec 24, 2004 4:07 pm

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
grahamg
 
Posts: 752
Joined: Fri Oct 03, 2003 3:15 pm
Location: Midlands UK

Postby bcusick » Fri Dec 24, 2004 4:14 pm

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.
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Re: Displaying Found Count (Like FMP)

Postby amcgilly » Thu Dec 29, 2005 6:04 am

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?
Adrian McGilly
Servoy Developer

Image
amcgilly
 
Posts: 375
Joined: Fri Dec 09, 2005 12:03 am
Location: San Francisco, CA

Postby patrick » Thu Dec 29, 2005 12:45 pm

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...
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany


Return to How To

Who is online

Users browsing this forum: No registered users and 14 guests