Dynamische Tabelle: 2 unterschiedliche Zeilen auf Knopfdruck hinzufügen
Verfasst: 12.08.2015, 10:46
Hallo,
ich möchte über einen Button (das vordefinierte Objekt "Element in Teilformular einfügen") in meinem PDF (s. Anhang) jeweils die 2 unterschiedlichen Zeilen hinzufügen. Das funktioniert auch soweit, allerdings werden sie in der falschen Reihenfolge hinzugefügt. Es soll immer so aussehen: Zeile 1, Zeile 2, Zeile 1, Zeile 2 usw.
Desweiteren sollen über den "-"-Button die 2 Zeilen wieder entfernt werden.
Ich habe noch keine große Erfahrung mit JavaScript und habe mich an dem vom Programm automatisch erstellten Code versucht ("+"-Button). Ich habe das erstellen einer neuen Instanz kopiert. Das hinzufügen funktioniert, die Reihenfolge stimmt aber nicht. Liegt das am falschen Index?
Weiß jemand Rat?
Gruß,
Axel
ich möchte über einen Button (das vordefinierte Objekt "Element in Teilformular einfügen") in meinem PDF (s. Anhang) jeweils die 2 unterschiedlichen Zeilen hinzufügen. Das funktioniert auch soweit, allerdings werden sie in der falschen Reihenfolge hinzugefügt. Es soll immer so aussehen: Zeile 1, Zeile 2, Zeile 1, Zeile 2 usw.
Desweiteren sollen über den "-"-Button die 2 Zeilen wieder entfernt werden.
Ich habe noch keine große Erfahrung mit JavaScript und habe mich an dem vom Programm automatisch erstellten Code versucht ("+"-Button). Ich habe das erstellen einer neuen Instanz kopiert. Das hinzufügen funktioniert, die Reihenfolge stimmt aber nicht. Liegt das am falschen Index?
Code: Alles auswählen
Formular.P1.sfrTabelle.Tabelle1.Zeile1.#subform[0].#subform[1].Teilformularschaltfläche1hinzufügen::click - (JavaScript, client)
/*
This button will insert one instance of the repeating subform or table row.
bCalc: Flag - true if the new instance might be referenced by other calculations, otherwise false.
message: The error message displayed.
*/
var bCalc = true;
var message = "Sie haben die maximale Anzahl zulässiger Objekte erreicht.";
// DO NOT MODIFY THE CODE BEYOND THIS POINT - 9.0.0.2.20101008.1.725030.725025 - Subform_Instance_Controls_IRM.xfo.p2
var oWrapper = this.parent.parent; // The outer subform built in to the object, enclosing the button group.
var oTargetSubform = oWrapper.parent; // The subform or table row the controls are intended to manipulate.
var oTargetSubform1 = Formular.P1.sfrTabelle.Tabelle1.Zeile2;
var oManager = oTargetSubform.instanceManager; // Get the instance manager.
var oManager1 = oTargetSubform1.instanceManager; // Get the instance manager.
var nMaxCount = oManager.occur.max; // Get the maximum number of subform occurrences allowed.
var nSubCount = oManager.count; // Get the current number of instances.
// Proceed if the maximum number of subform occurrences has not been reached.
if ((nMaxCount == "-1") || (nSubCount < nMaxCount)) {
// Invoke the Instance Manager.
var oNewInstance = oManager.addInstance(1);
// Fire the form calculations.
if (bCalc == true) {
// Execute all the form calculations.
xfa.form.recalculate(1);
}
// Move the new subform below the current one.
var nIndexFrom = oNewInstance.index;
var nIndexTo = oTargetSubform.index + 1;
oManager.moveInstance(nIndexFrom, nIndexTo);
// Invoke the Instance Manager.
var oNewInstance1 = oManager1.addInstance(1);
// Fire the form calculations.
if (bCalc == true) {
// Execute all the form calculations.
xfa.form.recalculate(1);
}
// Move the new subform below the current one.
var nIndexFrom1 = oNewInstance1.index;
var nIndexTo1 = oTargetSubform1.index + 1;
oManager1.moveInstance(nIndexFrom1, nIndexTo1);
} else {
xfa.host.messageBox(message,"Insert Item", 3);
}
// END OF DO NOT MODIFY
Gruß,
Axel