Sunday, March 31, 2013


[Live Demo]


Note : A newer version of this plugin is released please check the same by clicking on this link

Well I have been working on this new component "PageblockTable Enhancer" for a while and am trying to merge all the functionality that were featured in my earlier components " Sortable Pageblock table" and "Enhanced PageBlock Table".

The version 2.0b brings in some exciting changes like inclusion of Pagination along with the Sorting capability.

Check out the demo of the newest version here




How to use?

Parameter :

  • targetPbTableIds : comma-separated Ids of the target Pageblock tables




 <c:PageBlockTableEnhancer targetPbTableIds="mid,mid2"/>    
   <apex:pageBlock >  
       <apex:pageBlockTable value="{!accounts}" var="acc" id="mid">  
         <apex:column value="{!acc.Name}"/>  
       </apex:pageBlockTable>   
        <apex:pageBlockTable value="{!accounts}" var="acc" id="mid2">  
         <apex:column value="{!acc.Name}"/>  
       </apex:pageBlockTable>     
   </apex:pageBlock>





PS: This is a beta version of the plugin, some bug may exists, If you find one, I will be more than happy to resolve them.

Sunday, March 17, 2013


Fieldsets are one of the feature that you may use to make your visualforce dynamic. They are dynamic and allows display of component on the VF page dynamically. We  can add, remove, or reorder fields in a field set to modify the fields presented on the Visualforce page without modifying any code. Fieldsets are not very new to Force.com, but I have a habit searching for syntax before writing one, so writing this one for my reference and all others like me ;) .

Below are some of the example to show how fieldsets can be used in VF page.


  • Simplest example
<apex:page controller="Account_Con">   
   <apex:repeat value="{!$ObjectType.Account.FieldSets.AccountDetails}" var="f">    
    <apex:outputText value="{!myAccount[f]}" /><br/>   
   </apex:repeat>   
  </apex:page>   


  • To render a PageBlocksection
 <apex:page controller="Account_Con">  
   <apex:pageBlockSection>  
        <apex:repeat value="{!$ObjectType.Account.FieldSets.AccountDetails}" var="f">    
            <apex:outputField value="{!myAccount[f]}" />   
        </apex:repeat>   
   </apex:pageBlockSection>  
  </apex:page>   

  • To render a PageBlockTable
 <apex:page controller="Account_Con">  
   <apex:pageBlockSection>  
        <apex:pageBlockTable>  
             <apex:repeat value="{!$ObjectType.Account.FieldSets.AccountDetails}" var="f">    
                 <apex:column value="{!myAccount.Contacts[f]}" />  
             </apex:repeat>  
     </apex:pageBlockTable>         
   </apex:pageBlockSection>  
  </apex:page>   

All the above listed example dynamically display the records from the fieldset but what about the controller?
we can't just hardcode the queries here.To further extend the solution grab the code for the AVCommonUtil Class that generates query from fieldset/s.

Solution
You can use the util class to generate query dynamically from the fieldsets.

public class Account_Con(){   
  public Account myAccount{get;set;}   
  public AccountCon(){   
      AVCommonUtils util = new AVCommonUtils();  
      String query = util.generateQueryFromFieldSet('Account','AccountDetails',null,'LIMIT 1');  
       accObj = database.query(query);    
  }   
}   

Saturday, March 2, 2013




If you are going through my blog, few days back I pushed a new version of a Enchanced Pageblock Table. The main draw back of this component is to you have to modify your existing controller to provide the FieldList to the component.

But what If I give a new plugin that can work on existing Page block tables and that to without any code changes in the controller ?

So here is the initial version of The PageblockTableEnhancer, that can be included into existing page to enhance your existing PageBlockTables. Just include the component into the page and specify Ids of the target PageblockTable in csv format.

Features
Currently PageblockTableEnhancer  only supports sorting. You can apply sorting feature to any number of tables in a page by using a single PageblockTableEnhancer  component.

How to use?

Parameter :

  • targetPbTableIds : comma-separated Ids of the target Pageblock tables




 <c:PageBlockTableEnhancer targetPbTableIds="mid,mid2"/>    
   <apex:pageBlock >  
       <apex:pageBlockTable value="{!accounts}" var="acc" id="mid">  
         <apex:column value="{!acc.Name}"/>  
       </apex:pageBlockTable>   
        <apex:pageBlockTable value="{!accounts}" var="acc" id="mid2">  
         <apex:column value="{!acc.Name}"/>  
       </apex:pageBlockTable>     
   </apex:pageBlock>  


Enhanced Page Block Tables



Codebase: