You need to sign in to do that
Don't have an account?

How Visualforce page block section hide & enable based on custom object picklist value ?
Hi Team,
How can we do Visualforce page block section hide & enable based on custom object picklist value ?
Thanks,
Lakshminarasimha.
How can we do Visualforce page block section hide & enable based on custom object picklist value ?
Thanks,
Lakshminarasimha.
You can use a boolean variable with rendered attribute and toggle the value based on action.
Do post here if you've any further questions.
Happy Coding!
Thanks for your reply.
I have one custom picklist with 3 options, i have created 3 pageblocksections with diffrent fields. If i select picklist value need to enable appropriate pageblocksection.
Please let me know how can we achieve this.
Thanks
Lakshmi.
Greetings to you!
Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
Screenshots:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Thanks for your reply.
I am not using picklist options like below.
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','None'));
options.add(new SelectOption('NRI','NRI'));
options.add(new SelectOption('Non-NRI','Non-NRI'));
return options;
}
I am using picklilst options directly from Standard controller Custom object.
Example :
<apex:inputfield value="{!Account.industry}"/>
based on this picklist i want to display pageblock sections accordingly, if i deselect picklist options need to disable the pageblock sections.
Please advise ....
Thanks,
Lakshmi.
Find below the sample code -
See below screenshots for the execution -
1. Page on load
2.When Industry = 'Section 1'
3.When Industry = 'Section 2'
Post here if you have any further questions.
Happy Coding!!
Thanks for your reply.
It is working but, we lost the remaining fields data when we change the picklist options, because entire page is refreshing.Please advise any alternative solution.
HI Khan Anas,
Thanks for your reply.
It is working but one issue, if we select picklist option it show related pageblock section, again if we select ' None ' option existing selected pageblock section not hidden.
Please advise how can we resolve this issue.
I have one more qurey, this functionality is not supported in detail page inline edit.is it possible ?
Thanks,
Lakshmi S.
It should not refresh the page becasue we are just rerendering the form which would make AJAX request and update the state.
Make sure, you are not calling any pagereference methods or having any javascript called "oncomplete" of actionsupport.
Happy Coding!