Expand my Community achievements bar.

Using Schemas when Adding Rows Dynamically

Avatar

Former Community Member
Hi all,



I am trying to create a form where we can add rows to a form using _Subform.AddInstance(1).



When I bind the rows to the schema, I end up with all of the rows containing the same data.



If I remove the binding it works fine.



Not having binding will mean that a full redesign is needed, as I use XMLife to import this into another application, so a schema is a must.



Is there any trick to this?? Or is there a workaround.



Please help.
4 Replies

Avatar

Former Community Member
I tried this out using the PO schema which comes with the samples and it works as I would expect - After I exported the data, it was all in correct order.



Make sure your binding is correct. Check the binding in your repeating subforms. You should have a [*] notation somewhere in the default binding box on the bind tab. It will either be on the subform which is repeat or on individual fields (if you go down to that level)

Avatar

Former Community Member
I am having the same problem but using all of the ideas stated in your answer do not work. I have a button that exists in a different subform that will add an instance of a repeated row for a table like structure. The repeated row contains another repeating subform that contains as many subforms as columns in the columns, which is tied to the input XML data.<br /><br />The code tied to the button click event below:<br /><b><br />----- TestProgram.section3.testing.controlActivity.controlProcedure.partC.testResultsSubform.#area[0].btnAddRows::click - (JavaScript, client) <br /><br />var newRow = lineItemSub.instanceManager.addInstance(0);<br />var numCols = headerSub.testLabelSubform.all.length;<br />var numRows = lineItemSub.all.length; <br /><br />app.alert( "Adding LineItem instance: numCols(" + numCols + "), numRows(" + numRows + "), index(" + newRow.index + ")" );<br />newRow.itemNumField.rawValue = numRows;<br /> <br /> //This acts exactly as the for loop before without the forced calculate events.<br /> //newRow.testPassedSubform.instanceManager.setInstances(numCols);<br /> <br /> <br /> //Create pass/fail dropdowns for each test per reference number row<br /> for( var i=0; i<numCols-1; i++ )<br /> {<br /> var newSub = newRow.testPassedSubform.instanceManager.addInstance(1);<br /> app.alert( "New subform index(" + newSub.index );<br /> <br /> //Force a calculate event on the summary columns, <br /> //this will cause it to fire further events in the summary column when the test pass dropdowns are changed.<br /> var updateCol = xfa.resolveNode( "summarySubform.rowData.columnData[" + i + "]" );<br /> updateCol.execEvent( "calculate" );<br /> }<br /></b><br /><br />The testPassedSubform contains a single dropdownList that is bound to boolean data. The testPassedSubform is repeated for each column in the table. When I change the dropdown, the changes are propagated to all the dropdowns in that row. Examining the output XML data, it's only created one instance of that data, not the 6 that I expect. And yes, both the row and column data have [*] in them. Any clues?

Avatar

Former Community Member
I have had the same issue and found the problem was another field somewhere else in the form with the same name (and "normal" binding) - in my case named "id" - like the field in the repeatable elements. Renaming the element fixed the problem.



Hope it helps,

Kolja

Avatar

Former Community Member
Does anybody have a working example that they would send me, as I am getting no success at all.



Thanks



Thierry