Hi all, I am wondering what is in your experience the best practice to pass complex parameters to embedded views.
This is my case: in a view I have an object
custom .values = {
'JobID': '1001',
'ProdOrder': '50-001',
'IssueDate': 'Jan 1, 2025' }.
...
}
The view receive 2 params:
- CertID - the record id of the certificate to edit
- ChangeData - a string with the str(system.date.toMillis(system.date.now())
A change script on ChangeData param calls a script on the Project Library loadData(self)
to populate the custom.values
object reading data from a DB.
The view contains 20 embedded views each is an instance of the same view-template.
Embedded views instance have a parameter 'dataArray' that has some components binded to the specific elements of the custom.values
object. "value" is the binded component.
Params.dataArray = [
{
"CurrentField": "JobID",
"dim": "180px",
"type": "label",
"value": "Job"
},
{
"CurrentField": "JobID",
"dim": "300px",
"type": "field",
"value": "DesignerDefaultVal"
},
{
"CurrentField": "ProdOrder",
"dim": "180px",
"type": "label",
"value": "Production Order"
},
{
"CurrentField": "ProdOrder",
"dim": "300px",
"type": "field",
"value": "DesignerDefaultVal"
}
]
Binding is, for example:
props.params.dataArray[1].value -> custom.values['JobID']
props.params.dataArray[3].value -> custom.values['ProdOrder']
When I run the main view in the Designer it works fine, but when I launch the application on the browser, the embedded views update their values randomly. Some show DB data, some shows values that I saved in the designer (DesignerDefaultVal).
I tried creating a custom.triggerRefresh variable where I write an incremental integer. I changed the binding to
props.params.dataArray[1].value -> custom.triggerRefresh
and a transform script:
def transform(self, value, quality, timestamp):
param=self.props.params.dataArray[1].CurrentField
retVal=self.view.custom.values[param]
return retVal
last row of code inside the loadData
function increments the custom.triggerRefresh.
No improvement.
I tested the use of system.perspective.sendMessage('UpdEmb', scope='page') in the loadData script and I wrote a message handler on the template view (the view used in the embedded view) that logs its execution on wrapper.log file.
The message handler is on the root and does a
self.getChild('fldValue').refreshBinding('props.text')
It works the first time I launch the application but then it stops working. I tested different scope values.
Beside the sendMessage problem, I feel that the timing of events is the root cause of the problem, I can't find any explanantion on events time sequence along visualization of components.
At this point I am wondering if I have to change the approach, I am missing something or I hit a bug.
Any hint is welcome, thank you.