Expand my Community achievements bar.

addRow button not adding rows in correct order.

Avatar

Former Community Member

I have a dynamic table that is working great for the most part, I didn't design it

but I am responsible for QCing it and cleaning up the code a bit.

There is one issue I found and can't seem to figure out: In a scenario where I add rows to the table (intializes with one row already), then try to delete the first row, then add another row to the end of the table it will instead add the row to the beginning of the table.  Adding any further rows, however, will be added correctly to the bottom of the table.

How do I prevent the row from being added to the top of the table?

Code:

Form.equipmentReq.subFlow.Table1.Row1.deleteRow::click - (JavaScript, both)

if

(Form.equipmentReq.subFlow.Table1.Row1.instanceManager.count > 1)

{

var rowIndex = $.parent.index;

Row1.instanceManager.removeInstance(rowIndex);

}

xfa.form.remerge();

Form.equipmentReq.subFlow.Table1.tableBottom.addRecord.addRow::click - (JavaScript, both)

Table1.Row1.instanceManager.addInstance();

xfa.form.remerge();

I've seen this exact code work fine in other forms and I've compared form settings with others using dynamic tables; I haven't seen anything different that would cause this issue.

3 Replies

Avatar

Level 10

Looks faulty at first sight,

var rowIndex = $.parent.index; is FormCalc syntax althought you set the event to JavaScript.

Replace it with

var rowIndex = this.parent.index;

Avatar

Former Community Member

Yes, I've noticed that in a lot of the other forms using a dynamic table, it never effected the result though.  I went ahead and changed it anyways, but still having the same issue.

Avatar

Level 10

Can you upload the form, so I can have a look onto?