Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Need help re-numbering table rows

Avatar

Level 2

I have dynamic table set-up to adds rows via the instance manager.

Each table row has a button to delete that specific instance.

The problem I’m having is that if a row is deleted in the middle of the table, the rows don’t re-number.

For instance, if the table has rows numbered 1, 2, 3 & 4 and row 2 is deleted, I want

the rows to be re-numbered as 1, 2 & 3. Instead, what I end up with is rows 1, 3 & 4.

The script I’m using to number the rows is:

this.rawValue=this.parent.index+1

I’ve read in other posts that this script used in a table will automatically update the

row numbers if a row is deleted.

For some reason it’s not working for me.

Any suggestions.

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

I created a sample for you ..have a look and let me know this is what you wanted.

Paul

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

I created a sample for you ..have a look and let me know this is what you wanted.

Paul

Avatar

Level 2

Paul,

It worked great!

Just one more question.

Is there a way to re-number rows using a decimal numbering format?

Action Items.PNG

I came up with this script through trial and error. I'm sure it's not the correct way to do this, but it seems to work.

The only problem is that it self destructs when you get to 6.10. In order to deal with this limitation, I have to set the maximum number of instances to 9.

this.rawValue = "7." + this.parent.index - ".9";

I've tried to incorporate this decimal numbering into the script you gave me to re-number the rows, but I can't get it to work.

Thanks for your help.

Kurt


Avatar

Former Community Member

In the script where you set the number use this expression instead.

6 + ((i + 1)/10);

Paul

Avatar

Level 2

Paul,

It works perfectly.....thanks!

There is only one other type of numbering/listing that I use in my forms and that's alphabetical. If you could help me out with re-numbering rows that are listed alphabetically, I'd be forever in your debt.

I'm listing the rows alphabetically (A. B. C. D.) using the below script.

this.Cell2.rawValue = String.fromCharCode(this.parent.index + 65)+".";

I tried putting this script in for the number but it isn't working. All of the subform instances/rows are numbered as "A.".

for (i=0;i<=T3.Detail.instanceManager.count;i++){
    xfa.resolveNode("Detail[" + i + "].Number").rawValue = String.fromCharCode(this.parent.index + 65)+".";

Kurt

Avatar

Former Community Member

In the for loop where you set the Number field you shodul be using the variable i and not the refernce to the subform index (this.parent.index). So it should look like this:

String.fromCharCode(i + 65)+".";

Paul

Avatar

Level 2

Paul,

Works great.....thanks for your help!

Kurt

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----