CANNOT make a foundset recalculate without loading a form

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

CANNOT make a foundset recalculate without loading a form

Postby bevil » Thu Aug 25, 2016 2:21 pm

I am stuck trying to get my form with checkboxes immediately searchable after calculating an addition checkbox option.

If I add an Application.saveData() on every iteration of the loop that adds a value to my field, it works, however this is slow.

If I databaseManager.recalculate(foundset) after the loop is run, it does nothing. If I databaseManager.recalculate(foundset.field), it does nothing.

If I scroll (relatively slowly) through a table view of the data which shows my field, and then search for the value, it works perfectly, however I can't expect the client to add a value, scroll to the end of the list and then search the value.

What am I doing wrong?
bevil
 
Posts: 163
Joined: Thu Oct 18, 2012 7:31 pm

Re: CANNOT make a foundset recalculate without loading a for

Postby sbutler » Thu Aug 25, 2016 5:53 pm

what is the dataprovider behind the checkbox? Is it a stored calc? Is it just 1 checkbox, or you have a value list of multiple choices on 1 form element?
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: CANNOT make a foundset recalculate without loading a for

Postby bevil » Thu Aug 25, 2016 6:09 pm

Hi Scott.

Thanks for the reply.

It is a stored text field calculation which is a concatenation of related records separated by ''\n', so there are multiple choices on one form element.

Hope all is excellent.

Bevil
bevil
 
Posts: 163
Joined: Thu Oct 18, 2012 7:31 pm

Re: CANNOT make a foundset recalculate without loading a for

Postby sbutler » Thu Aug 25, 2016 6:31 pm

I'd suggest avoiding stored calculations. A table event is almost always a better alternative.

Your core issue I would expect is that the data isn't saved. Scrolling through the list is forcing your calculate to run, which then saves it, which is why searching it afterwards works. Same thing when you call a manual save in a loop.

I'd expect that if you look at the database after you do databaseManager.recalculate, that the value in the DB isn't updated, which is why the search doesn't work. This is essentially the issue with calcs. You have limited control over how often they run, and especially with a stored calc, when the value gets stored in the DB.

So, I'd remove the calc (but keep the column). Then trap whatever event would cause a change in the checkbox via a table event, then set the checkbox column manually. This could be slow, but only if one event is causing many rows to change, in which case you might look at accomplishing it differently.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: CANNOT make a foundset recalculate without loading a for

Postby bevil » Fri Aug 26, 2016 11:44 am

Thanks Scott

I will see if I can change it..

Best

Bevil
bevil
 
Posts: 163
Joined: Thu Oct 18, 2012 7:31 pm

Re: CANNOT make a foundset recalculate without loading a for

Postby Bernd.N » Sun Aug 28, 2016 11:07 pm

It sounds as if you do a calculation of some kind just when you scroll through a table.
If that is the case, you maybe try to avoid such a calculation at all, because scrolling is mainly browsing data and should not need data operations at all.

If not maybe you explain in more detail which data has to change when you scroll, and why.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 11 guests