Answered
Hi, I am relatively new to JavaScript and LifeCyle but have been working with it for a couple months now. I have successfully created a table that is editable and expandable. Users can add and delete rows as necessary.
One thing that I have not figured out how to script is the ability for a user to move a row up or down within the table. I have found information about the moveInstance() function but without a background knowledge in JavaScript I am unsure how to get the required actions to work.
This first one moves the table row or in my case a subform up 1. If you want to work with table rows just change every occurance of the name AccountSF to the name of the table row.
if(AccountSF.index != 0)
{
var nIndexFrom = AccountSF.index;
var nIndexTo = AccountSF.index - 1;
AccountSF.instanceManager.moveInstance(nIndexFrom, nIndexTo);
xfa.form.recalculate(1);
}
This one moves the subform down 1.
var nIndex = AccountSF.index;
if((nIndex + 1) < AccountSF.instanceManager.count)
{
var nIndexFrom = nIndex;
var nIndexTo = nIndex + 1;
AccountSF.instanceManager.moveInstance(nIndexFrom, nIndexTo);
xfa.form.recalculate(1);
}
For these scripts to work the buttons they are attached to need to reside in the subform or row they are intending on moveing up and down.
StevenD