Omit All

What would be the least expensive way to show a form with an empty foundset?

I tried:

controller.loadRecords(null);

but this loaded a separate foundset on the form then the other forms of the same table.

And I think

controller.loadAllRecords();
controller.invertRecords();

and

controller.loadAllRecords();
controller.loadOmittedRecords();

could be very expensive.

when nothing is omitted

controller.loadOmittedRecords();

is the fastest and cheapest way to get an empty foundset.

Jan,
what if there are omitted records?

They will be shown :), what you actually want is an explicit way to clear a foundset? like controller.clearFoundSet() ?
Why whould you need this?

controller.clearFoundSet() ? uhm, that sounds good :D

The reason is that I want the users to find an empty foundset every time they enter this form from the main menu, it would be even better if I could call a controller.show() without having Servoy request all of the records.

workaround for now:

make a method and attach on the onShow property of a form:

controller.find()
field1 = "abracadabraabracadabraacradabra"
controller.search()
if(controller.getMaxRecordIndex() > 0)
{
plugins.dialogs.showInfoDialog('WOW!', 'You are a hell of a lucky guy that you have typed this into your field! You have won the deepfreezer!! ','OK');
}
else
{
//you have an empty foundset!
}

:lol: :lol:

Thanks HJK,
that’s quite a colorful way of explaining it :D

This is what I’ve been doing, a find/search that I know will not return any records, but I feel there should be a more elegant and less expensive way.

r.rios:
The reason is that I want the users to find an empty foundset every time they enter this form from the main menu, it would be even better if I could call a controller.show() without having Servoy request all of the records.

Attach an empty method to onLoadAllRecordsCmd property to leave it empty by default.

onLoadAllRecordsCmd? is this a form property?

or did you mean onShowAllRecordsCmd? this didn’t work either.

yes, onShowAllRecordsCmd add empty method prevents records being loaded by default. (just tested this again)

do you really want the form to be empty every time a user goes to the form? Or just the first time it enters that form?

The first time works if you override the onShowAllRecordsCmd
But then you also must say that you want to use a separate foundset because if you don’t then if you have other forms that builds on that table and those forms are shown first you will see that data.

if you always want a empty foundset when the users shows the form then you have to this, make this method:

if(controller.getMaxRecordIndex() == 0)
{
emptyFoundset = controller.duplicateFoundSet();
}
else
{
controller.loadRecords(emptyFoundset)
}

and attach that method to the onShow and onShowAllRecordsCmd

jcompagner:
do you really want the form to be empty every time a user goes to the form? Or just the first time it enters that form?

Every time a user enters the form from the main menu (specific form).

jcompagner:
But then you also must say that you want to use a separate foundset …

actually, I don’t. If I did then controller.loadRecords(null); would have been just fine and I believe is equivalent to your example below, but it creates a separate foundset for this form and I don’t want that.

OK then then the only solution is to have a clearFoundSet method..
That will make the shared foundset empty over all the forms that are build on that table.

Thanx a lot :D

Will this be in 2.0.1?

foundset.clearFoundSet() or orders_to_order_details.clearFoundSet() will be possible in Servoy 2.1 (the I18N release)

(the I18N release)

What’s that?

i18n (internationalization)