Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Create a new row, lock prior row from editing

Avatar

Level 3

LCD 9, Acrobat 9, Windows 7

Gurus –

I am trying to make a table for comments, and when you create a new row the prior row will lock for editing.

To add a row I put a button in the table with this code:

_Row1.addInstance(true);
xfa.for.recalculate(true);

I am not familiar with the code to move through a table index, so have no idea how to set this up so that in addition to those two lines above , code will do something along the lines of access = “protected” for all cells in the prior row.

Ideas?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

First, my script was incorrect. The readOnly must be in double quotation marks, eg: = "readOnly";

Also, you have to drop the Row1 in the readOnly lines and it should work. This is because the reference to Row1 is included in the pRow variable.

For example:

pRow.comment.access = "readOnly";

Hope that helps,

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi,

If you count the rows after you have added the new one, then you could use the .access method to set each object in the row to readOnly:

Something like:

_Row1.addInstance(true);

var previousRow = _Row1.count - 2; // minus 2 to get to the zero based intance number of the previous row

var pRow = xfa.resolveNode("Row1[" + previousRow + "]");

// lock objects

pRow.object1.access = readOnly;

pRow.object2.access = readOnly;

pRow.object3.access = readOnly;

pRow.object4.access = readOnly;

You could do something more elegant, like a loop through the objects, but this should suffice as there probably arn't many objects in the row.

Hope that helps,

Niall

Avatar

Level 3

Niall -

Thanks.  I have set this up but no access changes are happening.  The button I have is in the HeaderRow if that makes any difference:

Snap6.jpg

Avatar

Correct answer by
Level 10

Hi,

First, my script was incorrect. The readOnly must be in double quotation marks, eg: = "readOnly";

Also, you have to drop the Row1 in the readOnly lines and it should work. This is because the reference to Row1 is included in the pRow variable.

For example:

pRow.comment.access = "readOnly";

Hope that helps,

Niall

Avatar

Level 3

That did it, thanks!  I had thought those "" were necessary, and had tried it but still had the Row1. in the code.  DOH!