+ Start a Discussion
ravikanth321ravikanth321 

Render table (VF Component) based on picklists on that object and Text field from parent object .

Hi i have two objects Account and Offer .On offer object i have two picklist fields using this two picklists i am showing/rendering  a table (vf component ) ,But now along with two picklist fields i have to render like this: Check the logged in user and under user there is a field called "See Headline as Partner" now i have to map this field value with account name in my org and under that  account i have a new text field called "product hierarchy " now i have to render the table based on already existed two picklists and this product hierarchy text field value.





 
ravikanth321ravikanth321
Please find the code below
ravikanth321ravikanth321
Please find the existing VF Code below.
<apex:page standardcontroller="Offer_Template__c" showHeader="true" sidebar="false" extensions="NewOfferInitCtrl" tabStyle="Offer_Template__c">

    <apex:styleSheet value="{!URLFOR($Resource.jQueryUI, 'jqueryui/jquery-ui.min.css')}" />
    <apex:styleSheet value="{!URLFOR($Resource.ProductTreeSR, 'jquery_tree/dist/themes/default/style.min.css')}" />
    <script src="{!URLFOR($Resource.PlentiSR, 'PlentiSR/jquery-2.2.3.min.js')}"></script>
    <script src="{!URLFOR($Resource.PlentiSR, 'PlentiSR/jquery.base64.js')}"></script>
    <script src="{!URLFOR($Resource.ProductTreeSR, 'jquery_tree/dist/jstree.min.js')}"></script>
    <script src="{!URLFOR($Resource.PlentiSR, 'PlentiSR/iframe-resizer/iframeResizer.min.js')}"></script>
    <script src="{!URLFOR($Resource.jQueryUI, 'jqueryui/jquery-ui.min.js')}"></script>
    <!-- <apex:includeScript value="{!URLFOR($Resource.PlentiSR,'/PlentiSR/SliderResources/jquery-1.6.2.min.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.PlentiSR,'/PlentiSR/SliderResources/jquery-ui-1.8.16.custom.min.js')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.PlentiSR,'/PlentiSR/SliderResources/jquery-ui-1.8.16.custom.css')}"/> -->
    
    <apex:form id="NewOfferFlowPage">
        <apex:pageblock title="New Offer Flow" id="offerFlowPageblock"  >
         <apex:outputPanel id="pageMsgsPanel">
         <apex:pagemessages />
         </apex:outputPanel>
           
            
            <div id="dialogPos"></div>
            
            <apex:outputPanel styleClass="infoPanel" rendered="{!currentStep != 0}">
                <div style="font-weight:bold;">Current Offer Construct: {!headlineMap[headlineSelected]}</div> 

                <div style="font-weight:bold;">
                    <apex:outputPanel rendered="{!currentStep != 4}">Step {!currentStep} of 3</apex:outputPanel>
                    <apex:outputPanel rendered="{!currentStep == 4}">Offer Summary</apex:outputPanel>
                </div>
            </apex:outputPanel>

            <apex:outputPanel id="HeadlinePanel" rendered="{!currentStep == 0 || currentStep == 4}">
                 <apex:pageBlockSection columns="1" collapsible="false" title="Internal Offer Name">
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel for="offerTitle" escape="false" value="Internal Offer Name<font color=red size=2>*</font>" />
                        <apex:inputField id="offerTitle" value="{!offerObject.Title__c}">
                        </apex:inputField>
                    </apex:pageBlockSectionItem>
                    <!-- <apex:pageBlockSectionItem >
                        <apex:outputLabel for="offerType" escape="false" value="Offer Type<font color=red size=2>*</font>" />
                        <apex:inputField id="offerType" value="{!offerObject.Offer_Type__c}" />
                    </apex:pageBlockSectionItem>
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel for="offerObjective" escape="false" value="Objective<font color=red size=2>*</font>" />
                        <apex:inputField id="offerObjective" value="{!offerObject.Objective__c}">
                        </apex:inputField>
                    </apex:pageBlockSectionItem> -->
                </apex:pageBlockSection>
                
                <apex:pageBlockSection columns="1" collapsible="false" title="Offer Type Definition ">
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel for="channelType" escape="false" value="Channel<font color=red size=2>*</font>" />
                        <apex:inputField id="channelType" value="{!offerObject.RecordTypeId}" onchange="channelTypeUpdt();">
                        </apex:inputField>
                    </apex:pageBlockSectionItem>
                    <!-- May 31, 2016 - remove objective
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel for="offerObjective" escape="false" value="Objective<font color=red size=2>*</font>" />
                        <apex:inputField id="offerObjective" value="{!offerObject.Objective__c}">
                        </apex:inputField>
                    </apex:pageBlockSectionItem> -->
                    <!-- June 8, 2016 - remove offer headline
                    <apex:pageBlockSectionItem helpText="What type of offer do you want to create?">
                        <apex:outputLabel for="headlineList" escape="false" value="Offer Headline <font color=red size=2>*</font>" />
                        <apex:selectList id="headlineList" value="{!headlineSelected}" multiselect="false" size="1" onchange="refreshHeadline();">
                            <apex:selectOptions value="{!headlineList}" id="headlineListOptions"></apex:selectOptions>
                        </apex:selectList>
                    </apex:pageBlockSectionItem> -->
                    <apex:pageBlockSectionItem helpText="What type of offer do you want to create?">
                        <apex:outputLabel for="headlineList" escape="false" value="Offer Construct<font color=red size=2>*</font>" />
                        <apex:selectList id="headlineList" value="{!headlineSelected}" multiselect="false" size="1" onchange="refreshHeadline();">
                            <apex:selectOptions value="{!headlineList}" id="headlineListOptions"></apex:selectOptions>
                        </apex:selectList>
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
                
                <hr class="cstmHr" />

               <apex:outputPanel id="OfferLevelPanel" rendered="{!currentStep == 2 || currentStep == 4}">
                <apex:pageBlockSection columns="1" collapsible="false" title="Offer Item Level Definition">
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel for="itemType" escape="false" value="Item Type<font color=red size=2>*</font>" />
                        <apex:inputField id="itemType" value="{!offerObject.Offer_Level_Type__c}" onchange="offerLvlTpChange();" />
                    </apex:pageBlockSectionItem>
                    
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel for="itemLevel" escape="false" value="Item Level<font color=red size=2>*</font>" />
                        <apex:selectList id="itemLevel" value="{!offerObject.Offer_Level__c}" multiselect="false" size="1" onchange="offerLvlUpdt();">
                            <apex:selectOptions value="{!ItemLevelOptions}" ></apex:selectOptions>
                            <!-- <apex:actionSupport event="onchange" rerender="OfferLevelPanel" /> -->
                        </apex:selectList>
                    </apex:pageBlockSectionItem>
                    
                    <apex:pageBlockSectionItem rendered="{!RenderProductTree}">
                        <apex:outputLabel escape="false" value="Hierarchy<font color=red size=2>*</font>" />
                        <c:ProductTreeComp Mode="{!ProductTreeMode}" OfferId="{!offerObject.Id}" OfferLevel="{!offerObject.Offer_Level_Type__c}" 
                            OfferType="{!offerObject.Offer_Level__c}"  CallbackFunc="updateHeadline" CallbackAfterProdRefresh="updateHeadline" />
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>

                <hr class="cstmHr" />

                <apex:outputPanel styleClass="buttonPanel" rendered="{!currentStep != 4}">
                    <apex:commandButton value="Back" action="{!setBackStep}" styleClass="cstmBtn">
                    </apex:commandButton>
                    <apex:commandButton value="Next" action="{!setNextStep}" styleClass="cstmBtn">
                    </apex:commandButton>
                </apex:outputPanel>
            </apex:outputPanel>

            <apex:outputPanel id="SiteDefinitionPanel" rendered="{!currentStep == 3 || currentStep == 4}">
                <apex:pageBlockSection columns="1" collapsible="false" title="Site(s) Definition">
                    <apex:pageBlockSectionItem >
                        <!-- <apex:commandButton value="Select Site(s)" styleClass="cstmBtnLg" onclick="window.open('{!siteSelectURL}', '_blank');"/> -->
                        <apex:iframe id="siteSelectFrame" src="{!siteSelectURL}" scrolling="true" />
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>

                <hr class="cstmHr" />

                <apex:outputPanel styleClass="buttonPanel" rendered="{!currentStep != 4}">
                    <apex:commandButton value="Back" action="{!setBackStep}" styleClass="cstmBtn">
                    </apex:commandButton>
                    <apex:commandButton value="Next" action="{!setNextStep}" styleClass="cstmBtn">
                    </apex:commandButton>
                </apex:outputPanel>
            </apex:outputPanel>
            
            <apex:outputPanel id="PreviewOfferPanel" rendered="{!currentStep == 4}">
                <apex:pageBlockSection columns="1" collapsible="true" title="Offer Preview">
                    <apex:pageBlockSectionItem >
                        <c:previewOfferforPartner viewFromOffer="true" offerObject="{!offerObject}" logourl="{!logoURL}" ShouldDisplay="false" />
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
            </apex:outputPanel>
      
         <c:CustomDialog centerId="dialogPos" dialogId="cfmSbmtDlg" dlgTitle="Confirm Submit and Pre Order" 
           dlgMessage="Your offer was successfully submitted for approval. Would you like to pre-order this offer so that it is executed after approval?"
           dlgBtn1="Order" dlgBtn2="Return to Home" dlgFuncBtn2="directToHome" dlgFuncBtn1="directToOrder" dlgCloseFunc="directToOfferView" 
           dlgHeight="250" dlgwidth="460" /> 
         
         <c:CustomDialog centerId="dialogPos" dialogId="cfmSbmtSponsorDlg" dlgTitle="Confirm Submit and Pre Order" 
           dlgMessage="Your offer was successfully saved. No approval is necessary. Would you like to order this offer?"
           dlgBtn1="Order" dlgBtn2="Return to Home" dlgFuncBtn2="directToHome" dlgFuncBtn1="directToOrder" dlgCloseFunc="directToOfferView"
           dlgHeight="250" dlgwidth="460" />
          
         <c:CustomDialog centerId="dialogPos" dialogId="cnOfDlg" dlgTitle="Cancel Offer" 
           dlgMessage="Would you like to save as a draft before exiting?"
           dlgBtn1="Save and Exit" dlgBtn2="Exit" dlgBtn3="Cancel" dlgFuncBtn2="cancelWithoutSave" dlgFuncBtn1="cancelWithSave" 
           dlgHeight="200" dlgwidth="425" />
        </apex:pageblock>

        <apex:actionFunction name="updateHeadline" action="{!updateProductHeadline}" rerender="PreviewOfferPanel" />
        <apex:actionFunction name="channelTypeUpdt" action="{!channelUpdt}" rerender="PreviewOfferPanel,OfferLevelPanel" />
        <apex:actionFunction name="incentiveUpdt" action="{!incentiveUpdtForHeadline}" rerender="PreviewOfferPanel,IncentivePanel,OfferLevelPanel" />
        <apex:actionFunction name="offerLvlUpdt" action="{!updateProductHeadline}" rerender="PreviewOfferPanel,OfferLevelPanel" />
        <apex:actionFunction name="updateProdcutTree" action="{!updtOfferLevel}" rerender="OfferLevelPanel" />
        <apex:actionFunction name="exitWithoutSaving" action="{!cancelOffer}"/>
        <apex:actionFunction name="exitWithSaving" action="{!saveandExit}"/>
    </apex:form>
    
    <c:ProductTreeJS />
    
    <script>
        var j$ = jQuery.noConflict();

        var addSiteResize = function() {
            j$('[id$=siteSelectFrame]').iFrameResize();
        }
        
        var offerLvlTpChange = function() {
            updateProdcutTree();
            if('{!currentStep}' == '4') {
                updateHeadline();
            }
        }
        
     
    </script>

</apex:page>