0

I want to have a p:datatable which contains one column having a treenode in each cell. How should I implement this? I'm new to jsf/primefaces. Any example is really appreciated. Thanks for any help!


   col1   |    col2
-------------------------------------------
   data1  |    node1
          |      |--- node2
          |      |--- node3
          |             |--- node4
------------------------------------------
   data2  |    node5
          |      |--- node6
---------------------------------------------

Here is my original datatable with all String columns:

    <p:dataTable id="datatable" value="#{userData.dataList}" var="data">
        <p:columns value="#{userData.dataTableColumns}" var="column">
            <f:facet name="header">
                <h:outputText value="#{column.header}" />
            </f:facet>
                <h:outputText value="#{data[column.property]}" />                      
        </p:columns>
    </p:dataTable>
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Jess
  • 1
  • 2
  • 1
    By putting a `p:tree` in there instead of an `h:outputText` – Kukeltje May 01 '17 at 20:21
  • Thanks for suggestion. But the rest of columns are still String. If I change it to p:tree, the rest of columns will show "Cannot convert 0 of type class java.lang.String to interface org.primefaces.model.TreeNode". – Jess May 02 '17 at 15:31
  • 1
    Have both a `p:tree` and a `h:outputText` there and use the `rendered` attribute based on your `column.property`. – Jasper de Vries May 02 '17 at 19:41

0 Answers0