What is a good way to reduce a foundset to a subset based on an index range from the original foundset? For example, if you have a foundset of 1,000 records, how can you reduce that foundset to only contain records that originally had an index of 550 through 875?
Find/search of if those records have something in common. If it’s only the index you can work with, I’d omit the records you want and then invert the foundset (since there’s less records you actually want). Offcourse you can also just omit every record you don’t want.
might there be a way to grab those lines from the index of pk’s in the FS (and then just send it back as a query)? would beat looping if the FS is large. Just thinking conceptually … this sort of thing exceeds my personal coding skills.
With regard to looping, the following seems to work well:
//load all records of the foundset without touching ui
for(var i = 0; i <= foundset.getSize(); i++)
{
foundset.getRecord(i);
}
//process records from last to first (thanks to a prior post by Johan Compagner)
for(var i=foundset.getSize(); --i>0;)
{
var record = foundset.getRecord(i);
if (record.test_id >= globals.start_index && record.test_id <= globals.end_index)
{
foundset.omitRecord(i);
}
}
foundset.loadOmittedRecords();
foundset.sort('test_id asc');