4 Replies Latest reply on May 23, 2007 4:08 AM by True Man

    DataTable problems when using SubTable

    True Man Newbie

      I have situation where I need to have a subtable inside a datatable and this subtable form a column of the datatable and there are other columns as well.
      For example, lets assume that I want a report showing the details of all orders made by different customers and each order has individual order item details.

      The outermost table has two colums one is customer name and the other is OrderDetails.

      The OrderDetails column has two columns one lists all the order items in this order and the other column shows the delivery address. Noet that that this second column should have a row span equal to no of other items. As the customer can have one or more orders this repeats over.

      I have several probelms. I name a few here
      1. With the following code the after adjusting the first subtable appeared alright but the columns after the subtable goes to the next row. But I want it in the same row.
      2. I though the rowSpan for customer for uinstance, should be equal to number of orders + 1 for the column header. But that doesn't quite seem to work and I have to add few extra.
      3. With IE the table looks Ok but with fire fox I see additional lines in due to the subtable
      4. Basically the whole table looks our of order.


      My xhtml code is

      <rich:dataTable var="customer" value="#{reports.customerList}">
      <rich:column rowspan="#{customer.noOfOrders + 1}">
      <f:facet name="header">
      <h:outputText value="#{messages.label_CustomerName}"/>
      </f:facet>
      <h:outputText value="#{customer.name}"/>
      </rich:column>
      <rich:column colspan="5">
      <f:facet name="header">
      <h:outputText value="#{messages.label_OrderDetails}"/>
      </f:facet>
      <ui:repeat var="order" value="#{customer.orders}" >
      <rich:column>
      <rich:subTable var="orderItem" value="#{order.orderItems}" >
      <rich:column>
      <f:facet name="header">
      <h:outputText value="#{messages.label_ItemPrice}"/>
      </f:facet>
      <h:outputText value="#{orderItem.price}">
      <f:convertNumber minFractionDigits="2" maxFractionDigits="2" groupingUsed="true"/>
      </h:outputText>
      </rich:column>
      <rich:column>
      <f:facet name="header">
      <h:outputText value="#{messages.label_ItemName}"/>
      </f:facet>
      <h:outputText value="#{order.name}"/>
      </rich:column>
      </rich:subTable>
      </rich:column>

      <rich:column rowspan="#{order.noOfOrderItems + 1}">
      <f:facet name="header">
      <h:outputText value="#{messages.label_DeliveryAddress}"/>
      </f:facet>
      <h:outputText value="#{order.deliveryAddress}"/>
      </rich:column>
      </ui:repeat>
      </rich:column>
      </rich:dataTable>

      Does anybody have any experience dealing with such a scenario with the datatable?

      Rajesh

        • 1. Re: DataTable problems when using SubTable
          True Man Newbie

          Can some one throw some light on this one please? Also, if incase it can't be achieved using richfaces, then what are the better alternatives to richfaces' datatable component particularly when I have one or more subtables in some of the column?

          • 3. Re: DataTable problems when using SubTable
            True Man Newbie

            Thanks for the pointer Ilya. But the example is very naïve and doesn't quite address the problem that I have mentioned. Just see how the City has been a row for itself and also the subtotal variable is repeated within the subtable itself.

            • 4. Re: DataTable problems when using SubTable
              True Man Newbie

              For the sake of clarity I have defined below the problem that I am trying to solve.


               --------------------------------------------------------------------------
              | Name | Order Details |
              ---------------------------------------------------------------------------|
              | | Date | ItemName | Qty | Price | Dly Address |
              | |------------------------------------------------------------|
              | | 1/5/02 |Item1 | 10 | 100.0| |
              | | 1/5/02 |Item2 | 3 | 200.0| 5, Clowns st |
              | Joe | 1/5/02 |Item3 | 50 | 400.0| TX |
              | | 1/5/02 |Item4 | 10 | 100.0| |
              | |------------------------------------------------------------|
              | | Date | ItemName | Qty | Price | Dly Address |
              | |------------------------------------------------------------|
              | | 5/8/02 |Item1 | 10 | 100.0| |
              | | 5/8/02 |Item2 | 3 | 200.0| 5, Clowns st |
              | | 5/8/02 |Item3 | 50 | 400.0| TX |
              | | 5/8/02 |Item4 | 10 | 100.0| |
              |--------------------------------------------------------------------------|
              | | Date | ItemName | Qty | Price | DlyAddress |
              | |------------------------------------------------------------|
              | | 3/5/02 |Item11 | 10 | 100.0| |
              | Sam | 3/5/02 |Item13 | 50 | 400.0| 75 Marrison Ave |
              | | 3/5/02 |Item14 | 10 | 100.0| VA |
              | |------------------------------------------------------------|
              | | Date | ItemName | Qty | Price | DlyAddress |
              | |------------------------------------------------------------|
              | | 6/5/02 |Item1 | 10 | 100.0| 66, Peter st |
              | | 6/5/02 |Item2 | 3 | 200.0| NY |
              | | 6/5/02 |Item3 | 50 | 400.0| |
              | | 6/5/02 |Item4 | 10 | 100.0| |
              |--------------------------------------------------------------------------|