function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GoForceGoGoForceGo 

VF page - Creating a button with drop down menu

Similar to the Dashboard button "Refresh" which has two options "Refresh Now" and "Schedule Refresh"

 

Does anyone have any pointers?

 

bob_buzzardbob_buzzard

I've done this in the past through scraping the Salesforce HTML that generates these sort of buttons.

 

Here's an example:

 

 

 

<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">Option1</a><a href="/" class="menuButtonMenuLink">Option2</a></div></div>
<script type="text/javascript">new MenuButton('MyMenu', false);</script>

 

Note that the div prior to the script element needs to be all on the same line - if you split it over multiple lines it breaks.  You'll need to replace the anchor hrefs with your target pages (or have onclick handlers).  

 

Note also that this is reliant on Salesforce not changing their css class names, which is always a possibility.  If that's a big concern, its worth duplicating these classes into your own stylesheet and namespace.

 

GoForceGoGoForceGo

Thanks Bob.

 

I want the href to point back to my controller which as the view state...put it another way, I just want to call different actions, similar to a commandButton action attribute. I guess I could write some javascript and perhaps use actionFunction or something.

 

 

 

 

 

 

bob_buzzardbob_buzzard
It may work with command links - I've not had to go that route so I can't say for sure. If it can't, you should be able to add an on click handler to the anchor tag and invoke an action function that way.
Boman@imtBoman@imt

Bob, this works, but the drop-down ONLY appears for the button on top, and nothing shows up when the lower button is clicked on. Any ideas? Thanks.

Sheraz HussainSheraz Hussain
This works, But the drop-down ONLY appears for the button on top and nothing shows up when the lower button is clicked on. Any ideas?Thanks.