using the button to add a row above instead of below

kitturaw4922957

28-09-2017

I am trying to create a table that will allow a user to hit a "button" and instead of the row being added to the bottom, I want it to be added to the top.

1313114_pastedImage_0.png

to this

1313115_pastedImage_1.png

I can get it to work only if the new row is added to the bottom. But this table sits at the bottom of the page, so I want it to build up.  I would appreciate any help at all.

Thank you!

Kitty

Accepted Solutions (0)

Answers (9)

Answers (9)

MinusZero

04-10-2017

Hi

How about trying to add the instance to the top as suggested before and then in the same event code change the Y position of the top of the table.

So as the table gets longer by a row height, the table Y position moves up by the same row height effectively looking like the bottom of the table stays where it is.

For example

//2in is the Y value of 2 inches

//use a variable to capture it's current position and calculate a new y value for it when the button is clicked.

Table1.y = "2in"; //javascript set Y position

Table1.y = "2in" //FormCalc set Y position

I found in my tests that this code by default returned a mm position eg: 69.85mm which meant i couldnt subtract the row height from it because of the text "mm"

If you can figure out how to get just the raw number Y value, make the calculation and give the table the new Y value, this might do what you are after.

kitturaw4922957

04-10-2017

I want the new blank rows to build up.

1317716_pastedImage_2.png

1317702_pastedImage_0.png

Kind of like this. I want the new blank row to go on top of the old row without the whole table moving down.(Newest on top).

That bottom row that has the text rev level is at the bottom of the page. 

Does this make sense?

Kitty

kitturaw4922957

02-10-2017

Not Exactly, I have:

this.resolveNode('RevTable._Row1').addInstance(1);

if (xfa.host.version < 😎 {

xfa.form.recalculate(1);

Ok getting closer. I used your suggestion above.

It added it to the top, but it moved everything down so the bottom row is now over top the footer.

so from this

1316346_pastedImage_2.png

to this

1316347_pastedImage_3.png

My goal is to have the table in the "rev level" column to show c,b, rev level.

Once I add even more rows the "b" row is now off the page.

Thank you,

Kitty

_Bruce_Robertson

MVP

01-10-2017

Hi Kitty,

To add a row to the bottom, you probably have something like;

this.resolveNode('Table1._Row1').addInstance(true);

You just need to change the addInstance() to inserInstance(0, true), zero being the position to insert the row at.

this.resolveNode('Table1._Row1').insertInstance(0, true);

Regards

Bruce