Menu

how to display row numbers

Help
2005-04-12
2012-10-08
  • Hemant Mahidhara

    How do I display the row number in the first column of the table?

     
    • Christopher K Koenigsberg

      Look at the documentation page about "Implicit Objects created by table"

      (<http://displaytag.sourceforge.net/tut_implicitobjects.html>).

      Specifically, the use of

      <%=pageContext.getAttribute("testit_rowNum")%>

      where "testit" is the value of the "id" attribute for the display:table.

       
      • Brian Barnett

        Brian Barnett - 2005-04-19

        I used a TableDecorator class to get row number to work.

        -- TableDecorator class
        -- I added a rowNum variable to the class (bean) for each row of the table and populate it in the table decorator.
        public class QueueTableDecorator extends TableDecorator {
        private int rowCounter = 0;
        public String startRow() {
        rowCounter++;
        CIDTQueueElementDTO cidtQueueElementDTO = (CIDTQueueElementDTO) getCurrentRowObject();
        cidtQueueElementDTO.setRowNum(rowCounter);
        return "";
        }
        public void finish() {
        rowCounter = 1; // reset to 1 so next time through the numbering starts at 1.
        }
        }

        -- JSP snippet
        <display:table width="100%" name="sessionScope.cidtQueueForm.cidtQueueList" class="simple" border="1" id="parent" requestURI="cidtQueue" decorator="com.scholar.view.decorator.QueueTableDecorator" >
        <display:column property="rowNum" title=""/>
        -- more columns --
        </display:table>

         
    • annab222

      annab222 - 2005-04-20

      To just display the row number, I've done the following...

      <display:table name="collectionList" id="collection" defaultsort="2" defaultorder="ascending" excludedParams="*" >
      <display:column title="#">
      <c:out value="${collection_rowNum}"/>
      </display:column>

      Where 'collection' in 'collection_rowNum' is the id value.

       

Log in to post a comment.

MongoDB Logo MongoDB