Skip to main content
Nintex Community Menu Bar
Question

How to show line number of row (ie: 1, 2, 3, etc)

  • July 10, 2024
  • 6 replies
  • 35 views

Forum|alt.badge.img+2

I am showing a list of opportunities and I’d like to see how many numbers I have like in the example below. How could I do this?

Thanks,
Charlie

This topic has been closed for replies.

6 replies

Forum|alt.badge.img+10

Hello! I just tried this and it works:

Firstly, create a template field on the table by clicking the ‘Add Field(s)’ dropdown on the table. You can label the template field anything you want.

In the template use:

<span class="counter"></span>

And make sure ‘Allow HTML’ is selected.

Then, add an inline snippet with the following code:

(function(skuid){ var $ = skuid.$; $(document.body).one('pageload',function(){ $('.counter').each(function(index, element){ $(this).text(index+1); }); }); })(skuid); 

This iterates through each ‘counter’ element and inserts the number for you.


Forum|alt.badge.img+10

This won’t work, however, for tables with multiple pages or where you are allowing the user to load more data into the table. That would require a different approach - and probably a better one!


Forum|alt.badge.img+2

Thank you Louis. I’ll try it out =)


Forum|alt.badge.img+10

Also, let me correct, you should be adding an ‘in-line’ javascript resource, rather than ‘in-line (snippet)’


Forum|alt.badge.img+5
  • July 10, 2024

Hi Charlie

You could use a custom field renderer on any field (e.g. Record ID) that looks like this

var field = arguments[0],&nbsp; &nbsp; value = arguments[1],<br>$ = skuid.$;<br>var index = 0;<br>field.model.data.map(function(o, i){<br>&nbsp; &nbsp; if(o === field.row) {<br>&nbsp; &nbsp; &nbsp; &nbsp; index = i;<br>&nbsp; &nbsp; &nbsp; &nbsp; return;<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; return;<br>});<br>field.element.append(index + 1);




Forum|alt.badge.img+13

There is a really simple, declarative approach that requires NO javaScript code: add a Template column to your Table with the following as its template value:

{{index}}

This is leveraging the {{index}} row merge variable which is available in row merge contexts.