Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » row number and sortable reports (ApEx 3.1.0.00.32, Oracle Database 10g Enterprise Edition Release 10.2.0.4.0)
row number and sortable reports [message #399422] Wed, 22 April 2009 02:55 Go to next message
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 #399450 is a reply to message #399422] Wed, 22 April 2009 04:59 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
I was able to find a solution. Smile The #ROWNUM# substitution string could be added also in a derived column in the report, so I added one, and moved it all the way to the left. I'll have to add it for all reports, but I guess I can live with this.
Re: row number and sortable reports [message #399540 is a reply to message #399422] Wed, 22 April 2009 18:56 Go to previous messageGo to next message
dr.s.raghunathan
Messages: 540
Registered: February 2008
Senior Member
if your report is based on query, it is not better to give title at the select clause itself.
even otherwise edit report attributes there the column title will get displayed and that can be changed to your own choice.
Re: row number and sortable reports [message #399642 is a reply to message #399540] Thu, 23 April 2009 04:55 Go to previous message
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

Previous Topic: INSTALL APEX AND HTTP IN 9.2.0.5
Next Topic: oracle APEX
Goto Forum:
  


Current Time: Wed Dec 04 19:48:32 CST 2024