I’m having an issue in developer with elements that have an onRender event attached.
If I open a form that has elements with an onRender in the developer client and then make any changes to that form in developer I start getting errors in the console and a popup warning.
The error says
“TypeError: Cannot read property “net_ppe” from (C:\Servoy\servoy_workspace6final\stock_tracker\forms\active_op_stock_data.js#18)
at C:\Servoy\servoy_workspace6final\stock_tracker\forms\active_op_stock_data.js:18 (onRender)”
If I take off the onRender events then everything works fine. Sometimes though it gets stuck in a loop and makes me force quit Servoy.
When running just the client the onRender works fine with no errors.
Before I submit a case I was wondering if anyone else had this issue or if it was just something local to my install.
I am having exactly the same issues with the OnRender event. I am trying to attach a procedure to the form onRender event to do conditional line colouring. Up to this point I have not been able to get this to work. A typical basic fuction is as follows:
function onRender(event)
{
/** @type {JSRecord<db:/sql1_track_data/rsp_fees>}*/
var rec = event.getRecord()
if (event.isRecordSelected()) {
event.getRenderable().bgcolor = '#009900';
} else if (rec.equity >= 100000) {
event.getRenderable().bgcolor = '#98c6f3';
} else {
event.getRenderable().bgcolor = '#8b9eed';
}
}
The issue is with the record field access. if there is any reference to the record in the function, the error is thrown:
Cannot read property “equity” from (C:\Servoy6_Workspaces\RT_Master_1\Advisor_Services\forms\ViewRelatedAccounts_sin.js#48)
Am I doing something wrong or is there a workaround for this??
for ‘line colouring’ I’d recommend using the CSS.
If you take a look at the sample CSS (this is an option when you create a stylesheet), you will see classes for even/odd/selected.
I actually did forget about using CSS for this, but in most cases I am looking for colouring based on some condition based on the data in the line… css is not going to help here and it is when I am trying to reference the ‘current’ record that the issue comes up. It seems onRender on a form is not binding the record being processed so it is not available as expected after the call to event.getRecord().
I have an application where most lists are colour coded to give a quick visual indication of the status of each record, so for this reason I have not been able to migrate to v6… yet.
I certainly will use CSS for any more basic needs though.