Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to clear the contents of a row

Avatar

Level 2
Hi Friends,

I have a table with around 10 rows and those rows have different fields.

when the user clicks the "Delete" button, the users should be able to delete the field values of that row..

Is there any easy way to achieve this, like deleting the whole row contents in once, instead of going into each field to deleting the contents..



Thanks

JJ
10 Replies

Avatar

Former Community Member
Are you trying to simply clear the fields in the row or delete the entire row (i.e if I have 10 rows and I delete a row I now have 9)?

Avatar

Level 2
Hi Paul,

Thanks again for trying to help me.

I wish to clear the fields in the row and once deleted there will be only 9 rows ( basically i will be hiding the deleted row once after clearing the field contents).



Thanks

JJ

Avatar

Former Community Member
Then simply remove the instance of the row and all data will disappear with it. You can use a removeInstance(instance Number) to accomplish this.

Avatar

Level 2
Hi Paul,

Do you have a sample code to share with me..

My code did not worked..



Thanks

Avatar

Former Community Member
subformName.instanceManager.removeInstance(instance number to remove)



Note the instances are 0 based.

Avatar

Level 2
Hi Paul,

my subforms are too deep from form like..

form1.subform1.subform2.subform3 and the delete button is in subform2 and i wish to remove the contents of subform3..



if that is the case how the code will look like..



Thanks

JJ

Avatar

Former Community Member
So if you use:



form1.subform1.subform2.subform3.instanceManager.removeInstance(instance number).

Avatar

Level 2
Hi Paul,

Sorry to say that, i am not using instance manager to create subfroms, the about code only removes that instance.



I have each 10 subforms inbuilt, i mean to say only one will be visible at a time and needs a script to remove the contents.



I found that xfa.host.resetData(fieldnames)can achieve this but still

looking for a script to get all the field names of the subform.



if you have any script which gets all the field names in a subform please share with me.



Thanks

JJ

Avatar

Level 7
Paul - On a similar note, I have a static table with 11 rows and I would like to remove form1.Table1.Row3



What will be the syntax ? I tried using




form1.Table1.instaceManager.removeInstance(form1.Table1.Row3);



but it didn't work



Any suggestions ?



Aditya

Avatar

Former Community Member
form1.Table1.Row3.removeInstance(instanceNumber)