FieldSets in Tables

One small tip, but very useful.

This is common requirement but I didn't find any post anywhere, so I thought of putting it together.

FieldSet is a magical concept which lets the admins take control on visibility of fields on Visualforce.

"It doesn't take a developer to add/ remove the fields on visualforce pages"

Step 1: Create a fieldset, Select your fields in pagelayout Editor. I grabbed Account name, Site, Description into my set "testfieldset".
Step 2: Create a visualforce page with following code and understand.


<apex:page id="pg" standardcontroller="Account" recordSetVar="accts">

<apex:form id="frm1">
    <apex:pageBlock mode="maindetail" title="Account List" id="pb1">
<!--      
  <apex:pageBlockButtons > 
           <apex:commandButton value="Save" action="{!quicksave}"/>           
   </apex:pageBlockButtons>
-->
        <apex:pageBlockTable value="{!accts}" var="acc" id="pbtbl1"> 
          <apex:repeat value="{!$ObjectType.Account.FieldSets.testfieldset}" var="fs1" id="pbt1rpt1">
           <apex:column value="{!acc[fs1]}">
           </apex:column>
           </apex:repeat>
       </apex:pageBlockTable>
      
    </apex:pageBlock>
     
</apex:form>
</apex:page>

If you want to go through the values and how they are getting populated, I suggest you hit F12 (windows) highlighting your browser and see through the developer console window.

I have also appended a javascript to popup something like this at the end of my page.

the snippet:
<script>
var a = document.getElementById("pg:frm1:pb1:pbtbl1:3:pbt1rpt1:0:j_id4").innerHTML;
alert(a);
</script>


Fieldsets come in handy with proper usage.

Comments

  1. Fieldsets In Tables >>>>> Download Now

    >>>>> Download Full

    Fieldsets In Tables >>>>> Download LINK

    >>>>> Download Now

    Fieldsets In Tables >>>>> Download Full

    >>>>> Download LINK 1R

    ReplyDelete

Post a Comment

Popular posts from this blog

Lightning spinner inside Button

Passing URL parameters to controller in Lightning components/ AURA

Nested AURA:IFs in Lightning Components Salesforce