Michal
Michal

Reputation: 3276

Confluence-how to add auto incrementing column to a table

I would like to have a template with a table which has first column with auto incremented number. When you hit tab in the last cell in the last row a new row is created (as it is now in Confluence's tables) and in first column number is incremented automatically.

I was looking for some macros (but I don't want to buy anything) and found only this one: https://marketplace.atlassian.com/plugins/org.swift.confluence.tablesorter which can't be used as a separate one without buying other plugins.

I was thinking about making my own macro and I would be grateful for pointing me direction where to start (I read confluence guide about macros). Do I need to use Velocity for that?

We have Confluence 4.3.6 installed

Upvotes: 2

Views: 4339

Answers (1)

Marco Forberg
Marco Forberg

Reputation: 2644

I haven't worked with velocity for a while and don't have a project around to test, but i think this should work for you:

#set($rowNumber = 0)
<table>
    #foreach( $product in $allProducts )
        <tr>
            <td>$rowNumber</td>
            <!-- your stuff goes here -->
        <tr>
        #set($rowNumber = $rowNumber +1)
    #end
</table>

Upvotes: 2

Related Questions