Expand my Community achievements bar.

Name of object "instances" in table row:

Avatar

Former Community Member
Hi,

I am a noob here with LiveCycle.

I am using the addInstance to add a row to a table as needed on the form:

form1.Subform10.Table2.Row1.instanceManager.addInstance(1);



I am finding that I cannot reference the new objects in the instances that are created (using the TextBox3[1] does not work).



How does LiveCycle name the object instances in the new table row instances in order to use them in scripting?



Thank you so much for your help!

Sylvia
16 Replies

Avatar

Former Community Member
Are you trying to access the objects from the same script that created them (i.e. access the items in the same script as the addInstance)?

Avatar

Former Community Member
No, I would like to reference them for populating duplicate information, and also for removing a specific row if needed.

Thanks for the response.

Avatar

Former Community Member
Figured out that it makes an instance of the row and uses the same object name:

xfa.form.form1.Subform10.Table2.Row1[1].TextField3.



My only problem now is trying to use a "removeInstance" button that will remove the last row added (not the first).



any suggestions?

Thanks!

Avatar

Former Community Member
You can use the removeInstance method with using an index:

row.instanceManager.removeInstance(row.instanceManager.count - 1);

Note: instanceManager.count gives you the current number of instances.

I think, that should help.

Avatar

Former Community Member
Hi,

you have to obtain the index of the last row created.

You can obtain the index when you create the last row or you can obtain the number of the rows from "nodes" object.

"Nodes" object rapresents the list of childs of an object like subform.



I hope this helps.



Bye,

Roberto

Avatar

Former Community Member
Thank you Gerhard and Roberto -- the removing of the last rows are working wonderfully!!

Avatar

Former Community Member
I am being asked if I can have a button now that will not remove the last row, but remove whatever row they have highlighted/focused.

Is there a way to use a hasFocus or another method in order to see what row/object has focus on the form?



Thank you so much for your help!!!

Sylvia

Avatar

Former Community Member
There is an example of doing this that ships with the product. Look at the Purchase Order Dynamic Interactive sample. Look in your Designer directory under the following folder:



EN\Samples\Forms\Purchase Order\Dynamic Interactive



Hope that helps



Paul

Avatar

Former Community Member
Thank you so much Paul - it is working beautifully :-)

Avatar

Level 2

I can remove individual instances of a row, using Javascript

Row.instanceManager.removeInstance(rowIndex)

but now I want to make sure that the last row left cannot be deleted. I tried using

if

(Table.Row.instanceManager.count > 1) then

  var rowIndex = $.parent.index;

  Row.instanceManager.removeInstance(rowIndex);

endif

but now none of the rows will delete.

What am I doing wrong?

Avatar

Former Community Member

Try...

if (this.parent.index > 0) then
    _Row.removeInstance(this.parent.index);
endif

Steve

Avatar

Level 2

Hmm, tested but that allows only the removal of the top row in the table.

I need the user to be able to remove any given row but I also don't want them to remove the 1 remaining row.

Avatar

Former Community Member

That is not the behaviour I see in the attached where the JavaScript on the delete button is as follows:

// form1.purchaseOrder.detail.deleteItems::click - (JavaScript, client)

xfa.host.messageBox("count " + purchaseOrder._detail.count);
xfa.host.messageBox("parent index " + this.parent.index);

if (this.parent.index > 0) {
    xfa.host.messageBox("deleting parent index" + this.parent.index);
    _detail.removeInstance(this.parent.index);
}

Avatar

Level 2

I can't open the attachment you are referring to.

I've attached the form I am working with. The problem we have is that if the user deletes all the rows then they can't add one back in which is why I want 1 row to stay and not be able to be deleted.

Avatar

Former Community Member

This new forum software is really getting under my skin. The attachments are getting queued so they can be run against a virus scanner. Unfortunately it seems competely random as to when, or if, the virus scanner processes the attachments and releases them for sharing.

Can you please forward your form to stwalker.adobe@gmail.com. I can take a look and respond with my sample.

Steve

Avatar

Former Community Member

Just set your min count to 1 in the subform object palette properties. This will ensure that you will always have one occurance

Paul