Current Position:Home > Render a column based on other column value in the same table

Render a column based on other column value in the same table

Update:11-30Source: network consolidation
Advertisement
JDev 11.1.1.6.0
This may be a silly question but I am stuck
I need to conditionally render a column say A. Condition is like if the value in the other column B of same table is equal to F. I should render column A only when this condition is satisfied. I have tried the following code:
<af:column sortProperty="PhoneNumber1"
sortable="false"
headerText="#{bindings.A.hints.PhoneNumber1.label}"
id="c146"
rendered="#{row.PhoneNumber1ResponseFlag eq 'F'}">
<af:outputText value="#{row.PhoneNumber1}"
id="ot130"/>
</af:column>
<af:column sortProperty="PhoneNumber1ResponseFlag"
sortable="false"
headerText="#{bindings.B.hints.PhoneNumber1ResponseFlag.label}"
id="c80" rendered="true">
<af:outputText value="#{row.PhoneNumber1ResponseFlag}"
id="ot129"/>
</af:column>
The data shown in the table for column  PhoneNumber1ResponseFlag is F. Still my condition is not working.

The Best Answer

Advertisement
Timo was saying that it is not possible to render the column in some situations and not in anothers, you will always have to render the column.
The best way to do this is instead of showing a column with the text ' ', show something meaningfull to the user. This is a DataWarehouse advice to you and may be usefull since you're using ADF in a area that uses DataWarehouse..
So the code could be something like this (based on Timo's code):
<af:column sortProperty="PhoneNumber1"
sortable="false"
headerText="#{bindings.A.hints.PhoneNumber1.label}"
id="c146">
<af:outputText value="#{row.PhoneNumber1ResponseFlag eq 'False.' ? row.PhoneNumber1 : 'No value applied.'"
    id="ot130"/>
</af:column>
<af:column sortProperty="PhoneNumber1ResponseFlag"
sortable="false"
headerText="#{bindings.B.hints.PhoneNumber1ResponseFlag.label}"
id="c80">
<af:outputText value="#{row.PhoneNumber1ResponseFlag}"
    id="ot129"/>
</af:column>
Hope that helps,
Frederico.

Database error: [Table 'ac_posts' is marked as crashed and should be repaired]

SELECT a.*, b.post_content FROM ac_posts a INNER JOIN ac_posts_content b ON a.ID = b.ID WHERE a.ID IN(1145069,351774,1578932,1653983,42014,90463,226702,446449,667811,693681) ORDER BY FIELD(a.ID, 1145069,351774,1578932,1653983,42014,90463,226702,446449,667811,693681);