Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

Recalculating all index numbers following deleting a row

Avatar

Level 2

I built a form having rows, where there is item numbers for each row such as 1 / 2 / 3 ...

 

I use following to add a new instance:

 

form1.Button.Button1::click - (FormCalc, client)
Table1._Row1.addInstance();

 

I use following to delete the last instance:

 

form1.Button.Button2::click - (FormCalc, client)
var nCount = Table1.Row1.instanceManager.count ;
//remove instance
Table1.Row1.instanceManager.removeInstance(nCount-1);

 

Below script is to show row numbers at the first column. 

 

form1.Table1.Row1.ItemNo::enter - (FormCalc, client)
var rowCount = this.parent.instanceManager.count;


form1.Table1.Row1.ItemNo::calculate - (FormCalc, client)
this.rawValue = this.parent.index + 1;

 

these above works great; however lately I needed to delete a random instance which is not the last row using:

 

form1.Table1.Row1.#subform[0].del_button::click - (JavaScript, client)

_Row1.removeInstance(this.parent.parent.index);

 

Now there is such a bug when I delete another instance which is not the last instance, row numbers do not recalculate.  

so lets say: I have row numbers 1 / 2 / 3 / 4 and delete the 3rd instance; row numbers listed appears   1 / 2 / 4

Is there a way each time an instance is deleted below script to work:

 

1 Accepted Solution

Avatar

Correct answer by
Administrator

@Krm974 Just checking in! Were you able to get this resolved? If you found your own solution, sharing the details would be a big help to others who might face the same issue later on. And if one of the replies here helped—whether it fully solved the problem or simply pointed you in the right direction—marking it as accepted makes it much easier for future readers to find. Thanks again for helping close the loop and contributing to the community!



Kautuk Sahni

View solution in original post

5 Replies

Avatar

Level 5

Hi @Krm974 

Can you please try by force re calculate 

// Delete the current row
_Row1.removeInstance(this.parent.parent.index);

// Force re-calculation of the form so row numbers update
xfa.form.recalculate(1);

If you don’t want to recalc the whole form, you can loop through just the table rows and reset numbering:

_Row1.removeInstance(this.parent.parent.index);

for (var i = 0; i < Table1._Row1.count; i++) {
    Table1.Row1[i].ItemNo.rawValue = i + 1;
}

 

Hope this helpful 🙂

 

Regards,

Karishma.

Avatar

Level 2

Dear Karishma, thanks for the support. Here follows is the outcome:

 

Either: 

xfa.form.recalculate(1);
for (var i = 0; i < Table1._Row1.count; i++) {
    Table1.Row1[i].ItemNo.rawValue = i + 1;
}

 

not worked for me. Most probabaly reason, as, I placed the delete button inside the row; after button is clicked it deleted the row instance and code stops.

 

 

Following Code worked in a separate button:

   

// Force re-calculation of the form so row numbers update
xfa.form.recalculate(1);

 

Following Code not worked even  in a separate button:

 

_Row1.removeInstance(this.parent.parent.index);

for (var i = 0; i < Table1._Row1.count; i++) {
    Table1.Row1[i].ItemNo.rawValue = i + 1;
}

 

So at this point my question is, is there a way to get the code work after the button (Which is including the code) is deleted?

Avatar

Correct answer by
Administrator

@Krm974 Just checking in! Were you able to get this resolved? If you found your own solution, sharing the details would be a big help to others who might face the same issue later on. And if one of the replies here helped—whether it fully solved the problem or simply pointed you in the right direction—marking it as accepted makes it much easier for future readers to find. Thanks again for helping close the loop and contributing to the community!



Kautuk Sahni

Avatar

Level 2

not yet, sorry

Avatar

Level 2

Hi Kautuk, your community seems very weak as for days I can not wait for an action.

I will ask for else where for a professional assistance. 

 

Maybe you should do better to boost your community.