Thursday, February 23, 2017

Visualforce - Beyond Basics Series 49 - Mark a table column as Required

How to give help text for a Table ?

In visualforce, table can be generated using PageBlockSection, PageBlockTable, DataGrid tags. If one wants to provide help text for a column, they need to use apex:facet tag.

How it will be useful to indicate Required Field ?

In some cases, developer may want to indicate a column as Required. So, it's possible to provide that in the table column header


Where is the Code ?

<apex:page standardController="Opportunity" recordSetVar="Opps">
<style>
.ReqHelpText {
display : inline-block;
width : 3px;
background-color : #c00;
}
</style>
<apex:sectionHeader title="Opportunities"/>
<apex:form>
<apex:pageBlock>
<apex:pageBlockTable value="{!Opps}" var="opp">
<apex:column>
<apex:inputField value="{!Opp.Name}"/>
<apex:facet name="header">
<apex:outputPanel>
<apex:outputText value="Opportunity Name - "/>
<apex:outputText value="&nbsp;" escape="false" styleClass="ReqHelpText"/>
<apex:outputText value=" It is a Required Field"/>
</apex:outputPanel>
</apex:facet>
</apex:column>
<apex:column value="{!Opp.StageName}"/>
<apex:column value="{!Opp.IsClosed}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
view raw gistfile1.txt hosted with ❤ by GitHub

Any Screenshots ?



Walk through in a video ?


No comments:

Post a Comment

Thanks for reading my blog !