Supplementing loadAllRecords()

My ShowAll method puts the id of the current record into a variable. Then runs loadAllRecords(), which loads 200 records. In order to keep the user on the record they were browsing I issue a```
foundset.selectRecord(variable);


Is it possible to load the first 200 records **plus** the out-of-range record the user was originally browsing?

Hi Morley,

I could swear that this has been answered on the forum before - but I cannot find any reference to it !

One possible solution that I thought of would be to collect the record pk’s of the 200 loaded records into an array and then loop through the elements and test for your stored pk.

If the pk is there then use the selectRecord and if not then use the Array functions to remove the last element and add your stored pk, then load the records via this array and then use selectRecord !

This may stimulate some further ideas !

Cheers
Harry

Harry Catharell:
One possible solution that I thought of would be to collect the record pk’s of the 200 loaded records into an array and then loop through the elements and test for your stored pk.

If the pk is there then use the selectRecord and if not then use the Array functions to remove the last element and add your stored pk, then load the records via this array and then use selectRecord !

I was thinking along the lines of identifying an array made up of the first 200 records plus the target record, load this set, then run getRecord(id). I’m unsure of the syntax required to do that. Would be faster than looping. Intuitively I suspect there’s a way to do that.

you don’t have to loop yourself.
That is what selectRecord() already does.

foundset.selectRecord(want_to_select_pk);
var size = 0;
while(current_pk != want_to_select_pk && size != foundset.getSize())
{
     size = foundset.getSize();
     foundset.getRecord(size); // this will load the next200 set
     foundset.selectRecord(want_to_select_pk); // try again.
}

This way it tries to select the right record.
And jumps constantly to the last record (loading the next set)
until there are no more sets and the size stays the same or the record is set.

Solved the problem – how to add a record to an existing found set. But the following won’t work until 2.2.1:

var id = record_id;
var set = foundset;
var array1 = new Array(set);
array1 = array1.push(id);
var dataset = databaseManager.convertToDataSet(array1);
controller.loadRecords(dataset);

Add the following and the focus will return to the original record.```
foundset.selectRecord(id);

the problem with that approach is that you never will get more then the 200 records displayed. Because those pk’s is the only think it will see.

And if you do a sort then it can be that that id is in completely the wrong place.

Also it can be that the id is not twice in the pklist. Once where it supposed to be and once at the end.

jcompagner:
the problem with that approach is that you never will get more then the 200 records displayed. Because those pk’s is the only think it will see.

And if you do a sort then it can be that that id is in completely the wrong place.

Also it can be that the id is not twice in the pklist. Once where it supposed to be and once at the end.

Are you saying 201 records cannot be displayed? When the user has a single record displayed and triggers a method which runs controller.showAllRecords(), it would be reassuring for the user to stay on that same record, not abruptly jump to some unknown.

201 records are displayed fine.
but you will never get 202