Attempting to dynamically change the color of a column based on its status value (Passed/Failed/InProgress) using jQuery.
I tried copying and pasting the table into jsfiddle, where it worked. However, when implemented in the actual XHTML file, the jQuery code does not seem to be functioning.
.xhtml
<ui:composition template="/pages/layout.xhtml">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('tr > td.y_n').each(function() {
colsole.log("in function");
if ($(this).text() === "Passed") {
colsole.log("in if");
$(this).css('background-color', '#FF0000');
} else {
colsole.log("in if else");
$(this).css('background-color', '#3AC709');
}
});
});
</script>
<p:dataTable id="idExecution" var="varTS" value="#{executionBean.lstLiveSelectedSuiteData}" style="margin-bottom:20px">
<f:facet name="header"> Steps </f:facet>
<p:column headerText="Status" class="y_n" >
<h:outputText value="#{varTS.status}" />
</p:column>
<p:column headerText="Error Message">
<h:outputText value="#{varTS.errorMessage}" />
</p:column>
</p:dataTable>
</ui:composition>
Note: The HTML provided in the jsfiddle is generated at runtime. (xhtml > html)
Anxious to see the color change reflecting the status column values.