Jump to content
Changes to the Jaspersoft community edition download ×

How to create an auto-numbered list NOT based on data query/count?


brossow

Recommended Posts

I am developing a report (in iReport Designer 5.6.0) that is mostly static and it includes a number of text fields that are optional based on very simple logic.  I need these to be a numbered list where the numbering is sequential only for those text fields that are displayed.  I know how to use a count-type integer variable when trying to, for example, enumerate query results.  But for the life of me I can't figure out a way to make a numbered list that isn't based on a group (there is nothing to be grouped) or counting the results of a query (the list isn't query results).

So for example, let's say I have the following text fields:

  • Apples
  • Oranges
  • Onions
  • Bananas
  • Carrots
  • Peaches

If I wanted to show them in a numbered list based on just those that are orange, let's say, then my list should look like this:

  1. Oranges
  2. Carrots
  3. Peaches

But using those same text fields, I may also want to create a sequentially numbered list where only the ones that are fruit are displayed:

  1. Apples
  2. Oranges
  3. Bananas
  4. Peaches

I found this old thread elsewhere via Google, but there's not enough info in it to help me solve this problem.  Is there any way to create a variable that auto-increments without needing to count query results, do grouping, etc.?  Obviously I'm not an expert developer and am looking for a solution that's contained within the template (i.e. no external server functions, scripts, etc.).

For what it's worth, my actual implementation will be long strings of text, not just one or two words -- the above is brief for better clarity. I tried using an HTML-formatted field and using numbered list tags, but the output was unacceptable.  (I need hanging indentation and other formatting that HTML within the text field isn't accomplishing, so I need the actual numbers in standalone text fields.)

Thanks in advance for any help!

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Thanks, but in your example the detail band is repeating and the number is incrementing based on results of a query (i.e. a list of countries resulting from the field $F{SHIPCOUNTRY}). In my case, the text displayed will not be the results of a query but rather static text that already exists in the report. The only dynamic elements will be the numbering (which I need to be sequential) and the visibility (based on the 'Print when expression') of each band, frame, etc. (that is, whichever of those I decide to use to determine visibility of the item and its corresponding number).

 

To be clear, the list items (Apple, Orange, etc.) that need to be sequentially numbered will _not_ be read in from a query but will already exist in the template. Hope that makes sense.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...