Wednesday, August 21, 2013

Drop-down button in a Visualforce Page

creating a drop-down button in a vf page..this is simple hack using standard salesforce styles

Code:
  <apex:page>
  <div class="menuButton" id="MyMenu">
    <div class="menuButtonButton" id="MyMenuButton">
       <span id="menuLabel" tabindex="0" style="">MyMenu</span>
    </div>
    <div class="menuButtonMenu" id="MyMenuMenu">
      <a href="/" class="menuButtonMenuLink firstMenuItem">Left VoiceMail</a>
      <a href="/" class="menuButtonMenuLink">Call in 1 day</a>
      <a href="/" class="menuButtonMenuLink">Call in 3 day</a>
      <a href="/" class="menuButtonMenuLink">Call in 5 day</a>
    </div>
  </div>
<script type="text/javascript">new MenuButton('MyMenu', false);</script>
  
</apex:page>

you can associate the actions by replacing the anchor tags with commandlinks or use ajax


Happy coding.....

Friday, August 2, 2013

Standard Salesforce DatePicker not working?

Some times Visualforce page with rerender sections, that standard DatePicker field based on Date or DateTime inputField tag was not working?

This was happend to me recently when I am developing some vf page. For this, a small hack that we can use is

if you have any field which is date or datetime, try to create the block which executes on every load with out and conditional renderings . This will allow to initialize the script and works for our custom inputField in vf page..

<div style=”display:none”>
    <apex:inputField value=“{!Account.Date_field__c}”/>
</div>


if you don't have any field which is date or datetime on the standard controller then create a property for the extension if you have any(if not you may need to created a date field on the standard controlller..but this doesn't make sense...in order to cover an issue we are not supposed to create  field..) which contains a set up object date or datetime field and make use of the same. like

public opportunity oppObj {get;set;}

<apex:inputField value="{!oppObj.closeddate}" rendered="false"/>

Hope this will help those we stuck with this kind of issue...Thank you.