Hello,
I am having some problems in using InstanceManager (dynamic tables). I try to add and delete new rows by using checkboxes. If a checkbox gets clicked a new row, with a value given from the checkbox, appears. If a checkbox gets deactivated, then the row, it has created, is going to be removed.
I use addInstance to add new lines into the table. In this case new line apperas always at the end of the table, which is just perfect! It is exactly the way I need it. But I have no idea how to pass over the value of my checkboxes right to the last line of my table.
I have tried to use moveInstance an it just messed up my form. (uploaded here: www.hs-augsburg.de/~nikg-fh/mypdf.pdf )
My Form:
My Code:
MyForm.page1.checkbox1::change - (JavaScript, client)
if (this.rawValue == "1")
{
var myInstance = xfa.form.MyForm.page1.MyTable._MyRow.addInstance(1);
var fromIndex = xfa.form.MyForm.page1.MyTable._MyRow.index;
var toIndex = myInstance.index;
// Value of col. "CheckBox-Value"
xfa.form.MyForm.page1.MyTable.MyRow.checkboxValue.rawValue = "CheckBox 1"; // <<<<<HERE IS THE PROBLEM!!!!!
// Value of col "fromIndex"
xfa.form.MyForm.page1.MyTable.MyRow.fromIndex.rawValue = fromIndex;
// Value of col "toIndex"
xfa.form.MyForm.page1.MyTable.MyRow.toIndex.rawValue = toIndex;
// Move Row
xfa.form.MyForm.page1.MyTable._MyRow.moveInstance(fromIndex, toIndex); // <<<< Don't need to use this Method?!
}
else
{
var rowToDelete = xfa.form.MyForm.page1.MyTable._MyRow.index;
xfa.form.MyForm.page1.MyTable._MyRow.removeInstance(rowToDelete);
xfa.form.MyForm.page1.deletedRow.rawValue = rowToDelete + 1;
}
it just gets messed up with this code, because of moveInstance (all checkboxes have similar coding):
any checkbox clicked:
checkbox1 klicked
checkbox 2 klicked:
checkbox 3 klicked:
Views
Replies
Total Likes
Hi,
I don't think checkboxes are a very intuiative way for the user to add rows.
That said, the main issue is that you are not specifying which instance of MyRow you want to set the value of checkboxValue. So this line:
xfa.form.MyForm.page1.MyTable.MyRow.checkboxValue.rawValue = "CheckBox 1"
Would become:
var i = page1.MyTable._MyRow.count - 1;
xfa.resolveNode("page1.MyTable.MyRow[" + i + "]").checkboxValue.rawValue = "CheckBox 1";
Also I would place the script in the click event of the checkbox, as the change event uses "xfa.event.newText". The click event uses "this.rawValue" as you have it.
Hope that helps,
Niall
THANKS!
Views
Replies
Total Likes