Hi Narcis,
I have tryed with your code and its fail when the table is ordered by another
column. However, I have solved the problem with a table decorator :) The code
run ok is:
public Integer getRowNum()
{
return new Integer(this.getListIndex()+1);
}
There is 2 methods in TableDecorator that count the rows number: getListIndex()
and getViewIndex()
Thanks :)
--- El vie, 16/1/09, Paslaru Narcis <paslaru.nar...@gmail.com> escribió:
De: Paslaru Narcis <paslaru.nar...@gmail.com>
Asunto: Re: [displaytag-user] Rv: Order in first column ¿?
Para: displaytag-user@lists.sourceforge.net
Fecha: viernes, 16 enero, 2009 12:12
Hi,
Have you tried using the implicit objects ?
http://displaytag.sourceforge.net/10/tut_implicitobjects.html
http://displaytag.sourceforge.net/11/tut_implicitobjects.html
Cheers,
Narcis
On Fri, Jan 16, 2009 at 12:01 PM, Ed Webb <e...@mws-systems.co.uk> wrote:
ffjavierr...@yahoo.es wrote:
>
>
>
> Hi,
>
> I am using DisplayTag in my tables and I have a problem. I would like
> the first column has a count of the number of the records. I have
> write the next column:
>
> <% int cont = 1 %>
> <displaytag:column>
> <%=cont++%>
> </displaytag
>
> and it works ok with one exception, if I order the table by other
> column the count is disordered. For example, I have the next table
> ordered by id(the first record is the tiles):
>
>
> count ------ id ----- name
> 1 ----------- a1 ----- Juan
> 2 ---------- a2 ------ Pepe
> 3 ---------- a3 ------ Arturo
>
> then, when I order by "name" then i have:
>
> count ------ id ------ name
> 3 ---------- a3 ------ Arturo
> 1 ----------- a1 ----- Juan
> 2 ---------- a2 ------ Pepe
>
> and i would like have:
> count ------ id ------ name
> 1 ---------- a3 ------ Arturo
> 2 ----------- a1 ----- Juan
> 3 ---------- a2 ------ Pepe
>
>
> Thanks and sorry by bad english
>
>
Try using a TableDecorator:
public class MyDecorator extends TableDecorator {
private int row = 0;
public String getRowNum() {
return "" + (++row);
}
}
and
<display:table ... decorator="MyDecorator">
<display:column property="rowNum"/>
...
</display:table>
(The above is untested)
Ed!
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user