When programatically adding an instance of a repeating subform using _SubformName.addInstance(), is there a way to specify a specific node in the XML data that the subform should bind to?
No you cannot change data bindings on the fly .....are you trying to addthe Instance and move it to a specific location (i.e. the 3rd instance of 10 instances)? If so ...you woudl nned to two commands ...one to add the instance (like you have done) and then a second command to move the instance from 10 to 3.
No, this has nothing to do with the order of the instances. It has to do with only adding a subset of instances for repeating data. For example, I have a section of my XML data that has x repeating nodes, with a bunch of data underneath. I want a subform to be added for each of those repeating data nodes, but I only want an instance in certain cases. Whether they are displayed or not depends on some complex rules. So I would like to have script in the container subform that loops through the repeating data nodes and decides if an instance needs to be added. If so, the script would do an addInstance and set the data binding to the specific data node. Then the fields inside the subform instance can just reference the data relative to the subform's binding and map correctly to the underlying data.
The alternative is to just bind the subform to the repeating data and perform the data check inside the subform, hiding the instance if it shouldn't be displayed. However the fields underneath are all bound directly to underlying data which will fire a bunch of events, and it seems wasteful to go through all of that processing just to have the whole subform hidden.
Ok Now I understand .....you still cannot change the binding statement dynamically so your only option is to allow the product to create the instances for every data node present then have logic that will hide the appropriate subform from the user.