Tsuki Shimizu
Tsuki Shimizu

Reputation: 1

p:dataList inside of p:dataTable

I'm using <p:dataTable> to show the values of my files. Inside of each file is a list of metadates. I want to show each metadate as an own column beside the other columns of the file. (I excluded the other columns to make the code more readable).

So, my problem is, that with the <p:dataList> it does not show the columns. The name of the meta is the same in every metadata, if someone believes this to be the problem.

I already tried to use <p:dataTable> instead of <p:dataList>, but as my customer originally wanted to have the metadata shown as own column this would not be my preferred way, but on the other hand it is working.

<p:dataTable id="fileList" var="f" value="#{reader.files}" rendered="#{reader.showFileTable()}">
    <p:dataList value="#{f.meta}" var="meta1">
        <p:column>
           #{meta1.value}
        </p:column>
    </p:dataList>

    <p:column headerText="Metadaten">
        <p:dataTable value="#{f.meta}" var="meta">
            <p:column headerText="#{meta.name}">
                 #{meta.value}
            </p:column>
        </p:dataTable>
     </p:column>
</p:dataTable>

I am really grateful for any help, how I could make the code work so that each metadate has it's own column in the fileList-dataTable.

P.S: I already tried c:forEach and ui:repeat which also didn't work.

P.P.S: I forgot to mention, that my customer sometimes don't want to see specific metadates, so it would be very nice when it is possible to do this with the suggested solution.

Upvotes: 0

Views: 3180

Answers (2)

fante76
fante76

Reputation: 55

Suppose you have this code:

<p:dataList id="fileList" var="f" value="#{reader.files}">
    <p:dataTable value="#{f.listItems}" var="meta1">
        <p:column>#{meta1.value}</p:column>
        <p:columns value="#{meta1.listItems}">...</p:columns>
    </p:dataTable>
</p:dataList>

Dynamic columns in nested dataTable are not generated: it seems p:columns cannot refer var like "f" and "meta1". I can understand "meta1" is not visible, because it's producing header's table, but I really can't understand why "f" is not visible at that time.

Any idea? Thanks.

Upvotes: 1

Nick Hol
Nick Hol

Reputation: 312

You can build columns dynamically in primefaces by using the <p:columns> tag see the vdl

check the primefaces showcase for an example

Upvotes: 1

Related Questions