Saturday, 14 December 2013

Code for alternate background color for rows in a pageBlockTable

Visualforce code:

<apex:page controller="sample">
    <apex:pageBlock >
    <apex:variable var="i" value="{!0}"/>
        <apex:pageBlockTable value="{!acnt}" var="acc">
            <apex:column >
                <apex:variable var="i" value="{!i+1}"/>
            </apex:column>
            <apex:column value="{!acc.Name}" rendered="{! IF((mod(i,2)) == 0, true, false)}" style="background:pink;"/>
            <apex:column rendered="{! IF((mod(i,2)) == 0, true, false)}" style="background:pink;" value="{!acc.Rating}"/>                     
           
            <apex:column value="{!acc.Name}" rendered="{! IF((mod(i,2)) == 1, true, false)}" style="background:yellow;"/>
            <apex:column rendered="{! IF((mod(i,2)) == 1, true, false)}" style="background:yellow;" value="{!acc.Rating}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>


Output:

Thursday, 12 December 2013

Disabiling developer mode using code

Code to Disable Developer mode in visualforce pages:

visualforce code :

<apex:page controller="newclass">
<apex:form >
 <apex:commandButton value="next" action="{!save}"/>
</apex:form>
</apex:page>

Apex Code :

public with sharing class newclass {
    public PageReference save() {
        PageReference pr = new PageReference('https://c.ap1.visual.force.com/apex/test1'+'?isdtp=vw');
        return pr;
    }
}

                                                            ---  OR ---

Append the following code to the URL

For example :

https://c.ap1.visual.force.com/apex/test?isdtp=vw