Menu

DisplayTag and Multiple Columns of Data

Help
Mark
2005-02-02
2012-10-08
  • Mark

    Mark - 2005-02-02

    (Please ignore my previous post - it had errors in it)

    Greetings - This problem is a little tough to explain so bear with me...

    By default, the DisplayTag library assumes that you just want your data (which can comprise 1 or more columns) in a single logical column. So say I display check numbers and check dates as follows:

    10000 (01/01/2005)
    10001 (01/02/2005)
    10002 (01/03/2005)
    ...

    This does not take advantage of the real-estate of the web page. It would be much better to display the data like this:

    10000 (01/01/2005) 10001 (01/02/2005)
    10002 (01/03/2005) 10003 (01/04/2005)
    10004 (01/05/2005) 10005 (01/06/2005)
    10006 (01/07/2005) 10007 (01/08/2005)
    ...

    So you have in this case 2 logical columns of data, with each column of data represented by 2 columns of information (check # and date) if you will. I cannot seem to find way to set this scenario up. I thought you could do something like this:

    <display:table name="<%=checks%>" id="check" length="<%=checks.size()%>" pagesize="25" offset="0">
    <display:column title="">
    <jsp:getProperty name="check" property="checkNumber" />
    (<jsp:getProperty name="check" property="checkDateStr" />)
    </display:column>
    <display:column title="">
    <jsp:getProperty name="check" property="checkNumber" />
    (<jsp:getProperty name="check" property="checkDateStr" />)
    </display:column>
    </display:table>

    But this does not work. You end up with this:

    10000 (01/01/2005) 10000 (01/01/2005)
    10001 (01/02/2005) 10001 (01/02/2005)
    10002 (01/03/2005) 10002 (01/03/2005)
    ...

    So each collection item is duplicated twice, since the <display:column> tag has no way of incrementing to the next item in the collection. Iterating through the collection only takes place at the <display:table> level, not the <display:column> level.

    So question: Is there a way to display multiple logical columns of data (as in my example above) ?

    Thanks in advance for any help!

    Mark

     
    • Rick Herrick

      Rick Herrick - 2005-02-03

      Mark,

      As best I know, there's no direct way to do this. I've tried to do something similar, except with a tabloid-column style display:

      1 6
      2 7
      3 8
      4 9
      5 10

      Because it was a fairly small display set, I ended up using <logic:iterate> tags from Struts to do this. It would be really nice to have the capability to do this directly within displaytag however.

       

Log in to post a comment.

MongoDB Logo MongoDB