Hi All,
We are having problem with using calculations. Below are 2 scenarios:
1) Stored Calculations:
- Consider a calculation which updates based on date
- We are able to sort on this Calculated column. (Required to sort on this column)
- Now, if sorting is applied on foundset and calculation is updated then next sorting fails to work because records are edited. We cannot apply AutoSave as this is not intended.
2) Simple Calculations (Not stored):
- Foundset sorting is working fine as expected.
- But we cannot sort on this Calculated Column.
Suggestion:
If for Stored calculations, some Servoy internal save data call may update calculations ONLY. As this will resolve edited record issue and finally resolve sorting issue. Or sort functionality may be enabled on simple calculations as well.
Any help shall be highly appreciated.
Regards
if the record where the stored calc is on has already other changes or you don’t want to autosave
then no the record will not be saved (so stored will not be in the database)
if we are going to make all kind of exceptions to this rule this is weird, you say don’t save then we don’t save.
Is very weird that stored calcs are then special, what if the depend on other unstored stuff and so on?
the calc could even be a foreign key that is calculated somehow but that thing its pointing to is not saved yet, then the save will fail…
(there could be more of those in the database that checks for valid data)
you can sort on un stored calls but you need to sort in memory using sort(function) that does mean you need all the data
sorting in the database on data thats not in the database is impossible
Stored Calculations
You don’t need to have autoSave enabled just identify when you need to save the edited records i.e.: before foundset.sort(), before foundset.find()
Saving the foundset will solve your sorting problem and allows you to keep the stored calculation which will make the sorting faster and easier
Non-stored Calculations
As jcompagner said, you can use foundset.sort(function) and it works like the regular js array sort function (receives two parameters and return -1, 0, or 1)
This is also the only option if you can’t save the edited records before sorting for stored calculations