Now that I know how to display the total number in found set (vs increments of 200), I’d like to modify my “go to record#” feature to work with large foundsets.
Attached is a picture of my navigation gizmo. The current record is 402, the found set 1987. If I type in any number up to 600 (where it currently says 402), it will go there. If I type in 1001, it does not; it remains at 402.
I see two possible solutions, neither ideal. One is to have the onDataChange method do a find instead of a go to. But then, the current found set is lost. Can capture the found set, then restore after going to record, but that may result in perceptible delays. The other is some bizarre method that goes to each record that is a multiple of 200 until being close to the target record. Sounds complicated. Plus, if the user was viewing records in the under 200 range, and then went to another in a range much higher, then more records have to be cached than are necessary (is this a bad thing?)
What would be cool, if Servoy must limit caching to 200 at a time: to be able to go to any record (without a find) in the found set, and if it is not already in cache, load it (or it and its 199 neighbors) into cache.
You need to check the number of records currently cached using controller.getMaxRecordIndex(). This will tell you whether you have 500 records or 200 or whatever.
Thanks, Bob. Sounds like option #2 is it. Most of our users will have record sets of less than 10,000, and it probably won’t be too noticeable. Plus, they will not often have a found set that is that many, anyway.
But still, consider a scenario where the user wants to go to record 60,001 or a million or whatever. That’s a lot of looping and increasing cache. Not possible to skip all the intervening blocks of 200 records and cache just the set of 200 that includes the desired record?
Am I correct that this is not only a programming problem but this implementationis also responsible for the unpleasant behaviour of the slider in a form, which in relativ length does show up according to the 200 records, but when you slide down (at once or in steps) the lenghth changes (get’s smaller) as there are suddenly more records, i. e. the total records has changed (and so on). For a user it’s quite irritating and I am not happy with this behaviour.
Best regards, Robert
bcusick:
You need to check the number of records currently cached using controller.getMaxRecordIndex(). This will tell you whether you have 500 records or 200 or whatever.
Well… I tried to do as Bob suggested, but I keep getting the same error message [see attached].
var curForm = application.getMethodTriggerFormName();
var curRecord = currentcontroller.getSelectedIndex();
var curMaxRecord = currentcontroller.getMaxRecordIndex();
var curFoundSet = databaseManager.getFoundSetCount(forms[curForm].foundset);
var numIncrements = Math.floor((curFoundSet-curMaxRecord)/200)
var x = 1
if (numIncrements > 0)
{
while (x <= numIncrements)
{
controller.recordIndex() = controller.getMaxRecordIndex(); x++;
}
}
It correctly identifies current rec#, max rec#, found count, and # “steps” needed to cache the desired record. If I don’t have the loop in, it doesn’t throw an error. When I put it in (or many variations I have tried), it reliably gives the error.
As it turns out, controller.recordIndex doesn’t exist anymore, fwiw.
What we end up with is:
var curForm = application.getMethodTriggerFormName();
var curRecord = currentcontroller.getSelectedIndex();
var curMaxRecord = currentcontroller.getMaxRecordIndex();
var curFoundSet = databaseManager.getFoundSetCount(forms[curForm].foundset);
var numIncrements = Math.floor((globals.recnav - curMaxRecord)/200)
numIncrements ++
var x = 1
if (numIncrements > 0)
{
while (x <= numIncrements)
{
forms[curForm].controller.setSelectedIndex(currentcontroller.getMaxRecordIndex()
);
x++;
}
}
…where globals.recnav is the field that both displays the current record, and is the input for the “goto” feature.
Thanks to David Workman for assistance with this, even though he thought is was a waste of time! I think it is a cool feature. Now if we could just get a vertical slider for custom controllers (as a standard u.i. element)…
Still curious about that error message, and generally interpreting such items. Anyone got a cool link for that?