You need to sign in to do that
Don't have an account?
Victoria Ukatu
Conditionally render Visualforce page based on picklist selection
Hi all,
I'm wondering how to conditionally render my Visualforce page based on the user's picklist selection. My picklist looks like this
Thanks!
I'm wondering how to conditionally render my Visualforce page based on the user's picklist selection. My picklist looks like this
<div class="slds-combobox-container" style="padding: 15px;"> <apex:form > <apex:selectList value="{!selectedList}" size="1" styleClass="slds-select"> <apex:selectOptions value="{!listOptions}"></apex:selectOptions> </apex:selectList> </apex:form> </div>where the user can choose Option A, Option B, or Option C. If they select Option A, I only want the records related to Option A to display, and the same idea with the other options. Right now all of the records are being displayed on the VF page regardless of which option I select. I know that there are answers out there related to picklists, but none that quite addressed this issue.
Thanks!
where display and tableofcontents are the id's of containers which contain the two parts of the page I want to re-render, e.g. And then in my Apex controller, within the get method which retrieves all of the data that I want to display, in the WHERE clause of my SOQL statement I set the lookup field between the Options and the display data equal to the variable which contains the id's of Option A, B, and C.
This was the key part that I was missing. In order for the page to know what data to conditionally render, I need to provide the id from the selection I chose from the dropdown.
If anyone is curious in the future about the full code I can go into more detail, but it was a pretty simple fix!
All Answers
Check the suggestions as mentioned in the above official article.
If it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
where display and tableofcontents are the id's of containers which contain the two parts of the page I want to re-render, e.g. And then in my Apex controller, within the get method which retrieves all of the data that I want to display, in the WHERE clause of my SOQL statement I set the lookup field between the Options and the display data equal to the variable which contains the id's of Option A, B, and C.
This was the key part that I was missing. In order for the page to know what data to conditionally render, I need to provide the id from the selection I chose from the dropdown.
If anyone is curious in the future about the full code I can go into more detail, but it was a pretty simple fix!