Wednesday, 3 August 2016

How to use FieldSet in Visualforce

Fieldset is a group of fields, you can use fieldset in Visualforce page to display those fields on page. When you are using fieldset in Visualforce to display fields, then you can add,remove & reorder fields very easily. When you are doing work with fieldset then you no need to code modifications to the page.

How to create Fieldset:

To create a Fieldset go to setup and search the object on which you want to create fieldset.



Click on fieldset and create a new fieldset, after that select all the fields which you want to include in your fieldset and then click on save button.
Now you can use your fieldset on your visualforce page and whenever you want to change the order of the fields and want to add or remove any fields on your page you can do that easily from your fieldset for this no need of coding.



Here is the Visualforce page coding which in which we are using Fieldset:

<apex:page standardController="Account">
<apex:pageblock >
<apex:form >
<apex:pageblockSection >
<apex:repeat value="{!$objectType.Account.Fieldsets.F1}" var="f">
<apex:inputField value="{!Account[f]}" />
</apex:repeat>
</apex:pageblockSection>
</apex:form>
    </apex:pageblock>
</apex:page>

With the help of this coding we can get this result:



  

No comments:

Post a Comment