简体   繁体   English

在Visualforce页面中覆盖选择列表值

[英]override picklist value in visualforce page

I am using a picklist in visualforce page, through apex:inputField in a form. 我正在通过表单中的apex:inputField在visualforce页面中使用一个选择列表。 I am saving that value in custom object. 我将该值保存在自定义对象中。 And that value is being saved in object. 该值被保存在对象中。 But when I will open that record in the same form (visualforce page). 但是,当我以相同的形式(Visualforce页面)打开该记录时。 When the form is being loaded that saved value was there. 加载表单时,保存的值在那里。 but when the form has been loaded, the value become null and --None-- was selected. 但是加载表单后,该值将变为null并选择--None--。

I tried to use javascript with alert, but it was showing that right value. 我尝试将Javascript与Alert配合使用,但它显示了正确的值。 I couldn't find out the issue. 我找不到问题。

I have used below code: 我用下面的代码:

<apex:pageBlockSectionItem id="Menopausal_StatusItem">  
                        <apex:outputText value="Menopausal Status:" />
                        <apex:outputPanel >
                            <apex:inputField value="{!msd.AgeVal__c}" id="ageValId" label="" style="display:none;"/>
                            <apex:inputField value="{!msd.Menopausal_Status__c}" id="Menopausal_Status" required="true"/>
                        </apex:outputPanel>
                    </apex:pageBlockSectionItem>
                    <!--<script>
                        alert('{!msd.Menopausal_Status__c}');
                        alert(document.getElementById('pageId:formId:pageBlockId:pageBlockSectionId:Menopausal_StatusItem:Menopausal_Status').value);
                    </script>
                -->

This is a dependent picklist (msd.Menopausal_Status_ c) and the controlling pick list is msd.AgeVal _c. 这是一个从属选择列表(msd.Menopausal_Status_ c),控制选择列表是msd.AgeVal _c。

Please help me. 请帮我。 Thanks in advance. 提前致谢。

I think this has to do with the dependent pick lists. 我认为这与依赖选择列表有关。 Do you have a value in AgeVal__c ? 您在AgeVal__c有值吗? If not, Menopausal_Status__c might not be correctly rendered when loading it in the Visualforce page. 如果没有, Menopausal_Status__c可能无法正确在Visualforce页面加载时,它呈现。

You could verify this by temporarily making the controlling pick list visibility, to check its content. 您可以通过暂时使控制选择列表可见性来检查其内容,从而验证这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM