Add record line number in a list

How do you add the record number for each line in a paging list ?

Have searched the community site and have not found a reference to this.

$index + 1

You can select this in the Data Bindings panel:

image

The index is zero-based - that’s why you need the +1.

Not sure how to apply that do i select a cell in the table or create a new cell and apply it there ?

It depends where you want the record number to appear. Assuming you want to add a new column for it, you could re-run the table generator (unless you've customised the table - in which your customisations may be lost):

Or you could add a new cell without using the table generator, in which case don't forget to add a new header too:

image

Here’s what I ended up doing thanks for your help works perfectly and saved a lot of time for me.

In the Paging table I added this

> <thead>
> 									<tr>
> 										<th>No.</th>

and then in the records row added this

> <td><a href="#" dmx-bind:href="group_Edit?class_id={{class_id}}">{{$index+1}}</a></td>

I added the Record # displaying as a link for the edit form to view just the single record .

1 Like

one more quick question on this I would also need each page to start the record # based on those being view. (sounds confusing I know. )

the code you gave works great it will provide a line number for each record showing if the paging query is set to display 25 records then each line # will be shown as 1-25 as it should. The issue is when you page to the next set of records (records 51 -75 ) the line numbers are still 1-25 how do I add the starting count to be for the query page being shown

This is what I’ve tried and the first line will be correct but all the lines after that will be the same # too

{{paging.data.query1.offset+1}}+{$index+1}}

1 Like

Well you just need the enter the whole expression between {{ and }} not separate as you will get two results then

like this ?
{{paging.data.query1.offset+1}{{ and }} {$index+1}} or like this
{{paging.data.query1.offset+1}{ and } {$index+1}}

these are not working though so what am I doing wrong ?

Just replace the ‘and’ with the whole expression.
{{ and }}

These curly brackets are never used as in your examples.

ok never would have gotten that from {{ and }} thanks Tom

Here’s the actual code that works now

{{$index+paging.data.query1.offset+1}}

if you want one expression it should be like this:

{{paging.data.query1.offset+$index+1}}

Maybe you should review some of the docs about formatting. You can use the regular Data Picker and formatter to build expressions visually.

I think the biggest issue with learning Wappler are definitions - I would never have guessed or known to look at the link for formatting Data.

Formatting Dynamic Data for Client Side Display means to me more of a styling display option type of thing not doing various calculations using data.

And I can see from my response I’m wrong also . Will review that section thanks.

how is that different from what I did

{{$index+paging.data.query1.offset+1}} ?

Is the same - I was regering your previous experiments

1 Like