I have a list of items displayed in a table with just an ID, name and 'Edit' button and a subform with details about the selected item. The backing schema has a 'selectedItem' place-holder as well as a list of items (the 'streams' node in the text below). The script for the 'Edit' button successfully extracts the index of the selected row but I'm having trouble getting the detail data for that item to display in the edit subform. The easiest approach would seem to be to set the subform binding to the selected row and remerge the data DOM and form DOM but that doesn't seem to do anything. The .XDP file is coded to bind the subform as follows:
<bind match="dataRef" ref="$.streams.waterbody[0]"/>
My script assigns the new binding value and calls remerge() as follows:
subform.bind.ref = "$.streams.waterbody[" + rowIndex + "]";
xfa.form.remerge();
Views
Replies
Total Likes
You cannot change the binding dynamically ....once the form is rendered changes to the bind.ref are ignored. This means that you have to manage the data yourself. You can extract the data from the dom and assign it to your fields.
Paul
That's good to know. I've figured out how to access the data DOM - can I create a node (with the appropriate sub-elements) in the data DOM, bind it to the subform, then assign the data node at run-time (with the selected row)? Would I then have to call xfa.form.remerge()?
Views
Replies
Total Likes
You cannot control when the binding happens ...it simply happens when the form is rendered. You can either let the binding happen and hide those fields that you do not want to see or push the value into the dom as you want them to bind (kind of the same thing as setting the fields yourself).
To acess individual items in the dom you would use the command xfa.datasets.data as the the root of the dom. Then you would follow your xml structure to get to the node tha you want. When you want to get the actual value of the node then you would use the value property. Something like this:
Fieldname.rawValue = xfa.datasets.data.form1.Page1.subform1.node.value
Remember that if an xml node has attributes then they will be turned into regular nodes in the dom prefixed by an @. I find it easier to display the dom so you can use the command app.alert(xfa.datasets.data.saveXML("pretty")) to visually see the structure. Or you can dump the contents of the dom into a multiline field so you can scroll through it.
Hope that helps
Paul
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies