Here are a few ways I've handled this situation. The first two are probably not applicable.
1) Use a t:popup to show the subitem values for a column. The displayed column value is the first subitem in the list. For a "name" column, for example, I'd show "Bob [4]" with the "[4]" in a different color, and when the mouse hovers over the "[4]", It'd show "Bob<br\>Fred<br\>George<br\>Tom" in the popup. 2) Use an inner dataTable to display the elements. The column would contain "<table><tr><td>Bob</td></tr><tr><td>Fred</td></tr><tr><td>George</td></tr><tr><td>Tom</td></tr></table>" when displayed. This can work fairly well when the data spans multiple columns. 3) Create a ItemHolder class containing a reference to an Item and a reference to a SubItem. Build a list of these with Items and Subitems as appropriate for display, and assign this list to the dataTable value. Then in your columns, display something depending on whether the item or the subitem value is non-null. It'll depend on the data how this might look. If the data is homogenious, then you can do something like <outputText value="#{(null == itemHolder.item) ? itemHolder.subItem.subName : itemHolder.item.name}" Or you can do something like <outputText rendered="#{null ne itemHolder.item}" value="#{itemHolder.item.name}"> <image rendered="#{null ne itemHolder.subItem}" data="#{itemHolder.subItem.picture.data}"> I think you can even go so far as to make the column itself rendered or not rendered, thus having the subitem columns and item columns differ in number, but you'd want to test this. This might look cleanest as you could list all of the item columns, then all of the subitem columns on your page. On 8/16/06, Michael Heinen <[EMAIL PROTECTED]> wrote:
I have a datatable with Items in it. One column in the datatable contains a link to show SubItems of an Item. These SubItems have to be displayed also in the datatable below the clicked Item in additional rows. The row (or the columns) of these SubItems have special css classes for visualization. The number of columns is the same for Items and SubItems. Moreover the rows (Items and SubItems) contain checkboxes. The datatable is bound to a PagedListDataModel in the BackingBean as mentioned in the WIKI. This dataModel contains a List of Items and I have to display e.g. 20 Items on each page, regardless of SubItems. The class Item contains a method getSubItems(). What is now the best approach to visualize these SubItems in the datatable? I think I have just to output additional table rows. a) Can I achieve this with a custom TableRenderer? The HtmlTableRendererBase contains a method afterRow(FacesContext facescontext, UIData uidata). Can I overwrite this method and place my logic there? uiData.getRowData() returns the last rendered Item. How can I now render additional rows with columns (and their children) for these SubItems? b) Or would it be easier to manipulate the dataModel and add the SubItems to the DataModel? I am not sure how to display the right number of Items on a page in this case if the DataModel contains both, Items and SubItems? Any help is highly appreciated Michael