jumping to a specific record

Hello,

I have a problem to jump to a specific record. I think this has been discussed before, but I couldn’t find it. The problem is this:

  • I am looking at some 90000 records
  • Every record can be linked to another record using a n:m table
  • Now I want to jump to one of the linked records, preferably not destroying the current selection

What I tried:

var vId = arguments[0]; // retrieve the ID that is looked for
controller.find();
id = vId;
controller.search(false, false); // search for the ID not destryoing the current selection
foundset.selectRecord(vId); // jump to the record

And what happens:

  1. If all records are shown, the record I am looking for is the only one left after searching, maybe because there was no selection before?
  2. If only a few records are shown, I am getting the result I want
  3. If many records are shown (some thousand), the wrong record is selected (not sure if the search record is added to selection)

Are my results expected? Is there a smart way to do this?

Thanks for any help
Patrick

Currently we select only within the loaded record PKs (normally 200), If you have that much records the question is do you realy want to load that much foundset pk’s?

No, I don’t. I just want that record to “appear”. The ideal would be to let that record become the first or something. The only thing that is not so nice is that a user looses his selection if he jumps to that record if a new search is fired.

But I suppose there is no clean way to do this (we are not using FM, are we). So if I have less than 200, I can do a find, if I have more I give a warning that the selection is lost. Or do you see some other way?

Hi Patrick,

Just had an idea, but haven’t tested it.
If your list of records is not too long you could do the following:

  • create an array with the id of the record you want to go to as the first element, followed by the pks of the current found set.
  • convert it back to a pkdataset and load the records.

Take a look at the database manager…

After final release of 2.2 we could make an addition to selectRecord as:
foundset.selectRecord(pk1,pk2,pkn[,allowOutOfOrderSelection])
so when many records are present in the foundset
foundset.selectRecord(23,true)
will always show the selected records as the first.