• Ajay Patel 30
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,

I have one object (business__c), it has two fields(session__c and timing__c) and both the fields are dependent field.
The timing__c field depends on the session__c field.
So i have created a visulforce page to achieve some functionality but onchnge field on actionsupport is not working properly means when user is selecting "Second Slot" from session__c field and timing__c field automatically populated as"3hrs" but it is not displaying any record in table(pageblocktable).

Controller Class:
public with sharing class Business_class{
           
           public List<business__c> businessDetailslist{get;set;}
           public business__c businessDetails {get;set;}
           public string timingsession{get;set;}
           
      public Business_class(ApexPages.StandardController controller){
              
            businessDetails = new business__c();
            
     }

    public void searchBusinessDeatils(){     
            
            businessDetailslist = [Select session__c,timing__c,description__c from business__c where timing__c =:timingsession limit 1];
       }
            
      
     public List<SelectOption> getItems() {
       
        List<SelectOption> options = new List<SelectOption>();    
               if(businessDetails.session__c=='First Slot'){
                    options.add(new SelectOption('5hrs','5hrs'));
                    options.add(new SelectOption('7hrs','7hrs'));
                 }
              else if(businessDetails.session__c=='Second Slot'){
                    options.add(new SelectOption('3hrs','3hrs'));
                  }

         return options;
    }
  
    
   }
  

Visualforce Page:

<apex:page standardController="contact" extensions="Business_class" sidebar="false">
<apex:form id="frm1">
      <apex:actionFunction name="srchfun" reRender="section_1"/>
      
           <apex:pageBlock title="{!$Label.details}" id="pbid" rendered="{!ShowBlock==true}">\
               <apex:pagemessages id="msg"/>
               <apex:pageBlockSection columns="2" id="cmid">
                
                      <apex:pageBlockSectionItem id="sctnid1">
                           <apex:outputLabel value="{!$Label.Session_name}"></apex:outputLabel>
                           <apex:inputField value="{!businessdetails.session__c}">
                           <apex:actionSupport event="onchange"  rerender="serchdetails,timingdat" status="counterStatus"/>
                           </apex:inputField>
                       
                     </apex:pageBlockSectionItem>
                    
                     <apex:pageBlockSectionItem id="sctnid2">
                        <apex:outputlabel value="{!$Label.Timing_slot}" />
                        <apex:outputPanel id="timingdat">
                             <apex:actionRegion >
                                <apex:selectList value="{!timingsession}" size="1" >
                                  <apex:selectOptions value="{!Items}"/>
                                  <apex:actionSupport event="onchange" rerender="serchdetails" status="counterStatus"  action="{!searchBusinessDeatils}"/>                                 
                               </apex:selectList>
                             </apex:actionRegion>
                       </apex:outputPanel>
                     </apex:pageBlockSectionItem>   
               </apex:pageBlockSection>
      
            <br/>
        <apex:outputPanel id="serchdetails">
          <apex:pageBlockTable value="{!businessDetailslist}" var="bdrt" id="istable" columns="3" >
                <apex:column headerValue="{!$Label.Session_name}">
                    <apex:outputField value="{!bdrt.session__c }"/>
                </apex:column>
                <apex:column headerValue="{!$Label.Timing_slot}">
                    <apex:outputField value="{!bdrt.timing__c}"/>
                </apex:column>
                <apex:column headerValue="{!$Label.Description}">
                    <apex:outputField value="{!bdrt.description__c}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:outputPanel>
        </apex:pageBlock>
        
</apex:form>
</apex:page>
              


Can any help me on this.

Thanks in adv.
Hi,

I have one object (business__c), it has two fields(session__c and timing__c) and both the fields are dependent field.
The timing__c field depends on the session__c field.
So i have created a visulforce page to achieve some functionality but onchnge field on actionsupport is not working properly means when user is selecting "Second Slot" from session__c field and timing__c field automatically populated as"3hrs" but it is not displaying any record in table(pageblocktable).

Controller Class:
public with sharing class Business_class{
           
           public List<business__c> businessDetailslist{get;set;}
           public business__c businessDetails {get;set;}
           public string timingsession{get;set;}
           
      public Business_class(ApexPages.StandardController controller){
              
            businessDetails = new business__c();
            
     }

    public void searchBusinessDeatils(){     
            
            businessDetailslist = [Select session__c,timing__c,description__c from business__c where timing__c =:timingsession limit 1];
       }
            
      
     public List<SelectOption> getItems() {
       
        List<SelectOption> options = new List<SelectOption>();    
               if(businessDetails.session__c=='First Slot'){
                    options.add(new SelectOption('5hrs','5hrs'));
                    options.add(new SelectOption('7hrs','7hrs'));
                 }
              else if(businessDetails.session__c=='Second Slot'){
                    options.add(new SelectOption('3hrs','3hrs'));
                  }

         return options;
    }
  
    
   }
  

Visualforce Page:

<apex:page standardController="contact" extensions="Business_class" sidebar="false">
<apex:form id="frm1">
      <apex:actionFunction name="srchfun" reRender="section_1"/>
      
           <apex:pageBlock title="{!$Label.details}" id="pbid" rendered="{!ShowBlock==true}">\
               <apex:pagemessages id="msg"/>
               <apex:pageBlockSection columns="2" id="cmid">
                
                      <apex:pageBlockSectionItem id="sctnid1">
                           <apex:outputLabel value="{!$Label.Session_name}"></apex:outputLabel>
                           <apex:inputField value="{!businessdetails.session__c}">
                           <apex:actionSupport event="onchange"  rerender="serchdetails,timingdat" status="counterStatus"/>
                           </apex:inputField>
                       
                     </apex:pageBlockSectionItem>
                    
                     <apex:pageBlockSectionItem id="sctnid2">
                        <apex:outputlabel value="{!$Label.Timing_slot}" />
                        <apex:outputPanel id="timingdat">
                             <apex:actionRegion >
                                <apex:selectList value="{!timingsession}" size="1" >
                                  <apex:selectOptions value="{!Items}"/>
                                  <apex:actionSupport event="onchange" rerender="serchdetails" status="counterStatus"  action="{!searchBusinessDeatils}"/>                                 
                               </apex:selectList>
                             </apex:actionRegion>
                       </apex:outputPanel>
                     </apex:pageBlockSectionItem>   
               </apex:pageBlockSection>
      
            <br/>
        <apex:outputPanel id="serchdetails">
          <apex:pageBlockTable value="{!businessDetailslist}" var="bdrt" id="istable" columns="3" >
                <apex:column headerValue="{!$Label.Session_name}">
                    <apex:outputField value="{!bdrt.session__c }"/>
                </apex:column>
                <apex:column headerValue="{!$Label.Timing_slot}">
                    <apex:outputField value="{!bdrt.timing__c}"/>
                </apex:column>
                <apex:column headerValue="{!$Label.Description}">
                    <apex:outputField value="{!bdrt.description__c}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:outputPanel>
        </apex:pageBlock>
        
</apex:form>
</apex:page>
              


Can any help me on this.

Thanks in adv.