I’ve created a dynamic form with an expanding table and I am having trouble getting instanceManager to do what I want.
I have 2 buttons, one button is in the header and adds rows to the bottom of the table when pressed using: Table3.Row2.instanceManager.addInstance(1);
It works.
Within each populated row, there is a delete button.
The delete button works using: Table3.Row2.instanceManager.removeInstance(1)
Is there a way to add an UP and DOWN button to each row, so when clicked the selected row moves either up or down the populated table?
Thank you
Solved! Go to Solution.
Views
Replies
Total Likes
I gave you a pseudocode to base yourself on it... the code i gave you is not good, it's just an exemple...
The idea of what you want to do is take all values in the selected row and shove it up or down one row...
so in the "up" button you should have something like this
As you can see, I'm taking the selected index of the row and the row just above by substracting 1 to the actual index
to do so with the "down" button you would have to add one to the index to get the next row
Don't forget to check if the row above or below exists by checking the index
Views
Replies
Total Likes
//store each values in a var or in an array
var tabValue = new Array(this.resolveNode("cell1").rawValue, this.resolveNode("cell2").rawValue);
//store values of the previous or next row
var tabValues = new Array(this.resolveNode("Row2[" + (this.parent.parent.index +- 1).toString() + "].cell1").rawValue, this.resolveNode("Row2[" + (this.parent.parent.index +- 1).toString() + "].cell2").rawValue);
and then you can give the values to the appropriate field
Views
Replies
Total Likes
Thank you Robert, do I apply the script to the button?
Views
Replies
Total Likes
on the up or down button yes
Views
Replies
Total Likes
Robert, I've dropped the script into the up and down button as a click event (JavaScript) but I am still unable to shift rows up or down. I am probably missing something.
I shared the file here: https://files.acrobat.com/preview/b4f6e4ad-0fb3-421a-b45b-316c42202cef
Views
Replies
Total Likes
I gave you a pseudocode to base yourself on it... the code i gave you is not good, it's just an exemple...
The idea of what you want to do is take all values in the selected row and shove it up or down one row...
so in the "up" button you should have something like this
As you can see, I'm taking the selected index of the row and the row just above by substracting 1 to the actual index
to do so with the "down" button you would have to add one to the index to get the next row
Don't forget to check if the row above or below exists by checking the index
Views
Replies
Total Likes
BOOM!
Sorry I misunderstood, it works perfectly!
thank you again!
Views
Replies
Total Likes
Robert, old post but the remove instance button is removing the wrong instances, for example, if I try to remove instance 4, it will remove instance 2. I have tried adding the button to the up and down script but it causes the script to not work. any idea how I can make this work?
Thank you
Views
Replies
Total Likes
I can help you sure, can you show me the code you are using to remove an instance?
Views
Replies
Total Likes
I got it shortly after posting! my code was
Table3.Row2.instanceManager.removeInstance(1)
I changed it to
Table3.Row2.instanceManager.removeInstance(this.parent.parent.index)
and it works perfectly! Thank you for the quick response
Views
Replies
Total Likes
Good job, no problem
Views
Replies
Total Likes
Views
Likes
Replies