Hi,
maybe another thing to add to my sample solution for Johan…
I noticed a problem when using onRender because my CPU usage went mad for Servoy and caused my fans to kick in on my MBP…
I am trying to use the onRender event to ‘highlight’ certain fields in a tab depending on record and related record values.
I have tried attaching all logic inside the form onRender and also (instead) in the specific field’s onRender, and with the related tab form set as Record, List or Table view, all same problem.
When there is more than one related record, it seems like onRender keeps on getting called in an infinite loop.
If there is no related record it doesn’t fire
If there is one related record, it (I think) fires once for each element on form
BUT, if there is more than one related record, it keeps firing round and round (I have put application.output ( ) calls in each onRender to see) and CPU usage goes from <10% to 70-100%!!
The relation is a simple one based on a PK to FK only.
Even if I just display the form on it’s own, as soon as there is more than one record, it goes mad.
Here is the code I put ion the onRender (or same code but just with the one condition specific to that field in each field onRender)
/** @type {JSRecord<db:/pro_conf/confline>} */
var $record = event.getRecord ( );
if ( $record != null )
{
if ( $record.confcode == null || $record.confcode == '' )
elements.confcode.bgcolor = '#ff0000';
if ( ($record.confinvrecip == 'Y') && ($record.confpaid == 'Y') && ( $record.confpayslip != null && $record.confpayslip != '') )
elements.confpayslip.bgcolor = '#ff0000';
if ( databaseManager.hasRecords ( $record.confline_to_corresp_by_booking ))
if ( $record.confline_to_corresp_by_booking.sageexported == null || $record.confline_to_corresp_by_booking.sageexported == '')
elements.confinvno.bgcolor = '#00ff00';
else
elements.confinvno.bgcolor = '#ff0000';
}
The relation confline_to_corresp_by_booking is a many-to-one relation , relating all records in that tab to an invoice to check if it has been exported to Sage (an accounts package) [but I just tried turning that test off and it still goes mad]
Have I done something really stupid & not understood how to code for onRender (entirely possible as I’m old school Servoy…)??
Is this a bug? (If so, surely it must have happened for someone else as well???)
Do I need to add this to my sample solution Johan?
Help!
[EDIT I just tried turning off my extra onRender’s, leaving just the form one and it doesn’t behave as badly i.e. it stops after ‘no of recs’ x ‘no of elements’ fires of onRender, BUT if I move the mouse over the records, it fires IF there is more than one record in the tab. I have one element with an onFocusLost event, but firing happens if I move over any element. It does stop firing when I stop moving over elements. Still happens even if I turn off onFocusLost…
/EDIT]
Thanks
Rafi