You need to sign in to do that
Don't have an account?
vikramkk
Hide/Unhide a section in a Page
Hi
I want to create a custom button in opportunity layout page, such that when I click the button, a section in opportunity should become hidden. When I click again it should appear again. Basically it should hide/unhide on successive clicks
You can achieve this if you are working with visualforce page, else I don't think you can conditionally render section on button clicks.
But if you are working in visualforce then here is the sample code which will conditionally render section on link click. You can change the command link to command button.
VFP :
Class :
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Thanks Ankit
This example helped me :)
Great! So if this helped you then please mark it as a solution :)
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Ankit,
Oddly I was coming to the dev board with a very similar question: how to rerender a section based on the value selected in a picklist. It looks like your solution is a good one but I notice it depends on a full page refresh. Isn't there a way to use the rerender param to accomplish this and avoid the full page refresh?
Apparently not for me as my example is not working:
In this example I've a custom picklist. I expect that when the value is changed on the picklist, the section "InfoBlock" will rerender. Indeed, the outputText does refresh EXCEPT when I choose 'HideMe' - then nothing changes. I expected the section to disappear.
What I was really going for was the converse, where the section would only appear when a certain value was selected. With the rendered param on InfoBlock looking for a == rather than an !=, the section never appeared.
What am I missing about the rerender parameter? Is there a way to do ajax-like show/hides without a full page refresh?
Ah...I am able to do what I want with the nifty apex:outputPanel. By changing my code to this...
<apex:page standardController="Case"> <apex:form > <apex:pageBlock > <apex:pageBlockSection > <apex:inputfield value="{!Case.Call_Type__c}"> <apex:actionSupport event="onchange" rerender="InfoBlock"/> </apex:inputfield> </apex:pageBlockSection> <apex:outputPanel id="InfoBlock"><apex:pageBlockSection rendered="{!Case.Call_Type__c != 'HideMe'}" id="SampleSendInfoBlock"> <apex:outputText value="{!Case.Call_Type__c}"/> <apex:outputText value="{!IF(Case.Call_Type__c=='HideMe','Should be Hidden', 'Peekaboo')}"/> <apex:inputField value="{!Case.Subject}" style="width: 100%"/> <apex:pageBlockSectionItem /> <apex:inputfield value="{!Case.ContactId}" style="width: 100%"/> </apex:pageBlockSection></apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page>
...it works like a charm.
Hi Ankit,
When i am executing code am getting following error..
Error: t Compile Error: Constructor not defined: [selectOption].<Constructor>(String, String) at line 11 column 20
I have used String.valueOf but its not getting through. can you please help as I am trying to use same code for my vf.
Thanks,
Amrin