row number and sortable reports [message #399422] |
Wed, 22 April 2009 02:55 |
c_stenersen
Messages: 255 Registered: August 2007
|
Senior Member |
|
|
In my reports I wish to have the row number appear as the leftmost column. When selecting rownum in the query, ordering the report will make the numbers scrambled. I then saw that it was possible to use the #ROWNUM# substitution string in the "before each row" part of the report templates. But I still have a problem.
I add this to "before each row":<tr><td class="rownum">#ROWNUM#</td>
I will get the row number for all the data rows, but in the header it will show the text #ROWNUM#. (The code added is the same there as well, and since there's no rownum for the header row it just shows the substitution string.) Is there any way around it? Can the header of this column be changed in any way?
Thank you
Cheers,
C.
|
|
|
|
|
Re: row number and sortable reports [message #399642 is a reply to message #399540] |
Thu, 23 April 2009 04:55 |
c_stenersen
Messages: 255 Registered: August 2007
|
Senior Member |
|
|
Yes, I figured it was quite OK to have it on a report by report basis. I couldn't add it to the select however. If I had a query like this:SELECT rownum, item_id, description
FROM item
When I would then click on the header of the description column it would sort the report by description. But the row numbers wouldn't be updated. So the entry with the description "AAA" might be shown first in the results, but the rownum column wouldn't show 1, but rather the row-number it would have in the unordered result. I don't know how apex does this behind the scenes, if they wrap it in an outer query and then sorts that one or something like that.
But adding a derived column in the report with just #ROWNUM# as the html expression solved it. The real number of the row is shown, so that no matter which field I sort on, the numbers are in sequence. And in the report attributes I can then change the header and other attributes of this column as for any column selected directly in the query.
Edit: The problem seems to be that the number will be the same for each page of results. If there are 15 entries per page and you have 60 rows in the result, for all of the four pages the rownum column will show the numbers from 1 to 15, rather than page two having the numbers from 16 to 30, page three having 31 to 45 and so on.
[Updated on: Thu, 23 April 2009 05:08] Report message to a moderator
|
|
|