0

Am trying to write a VF page which has details of the custom object and their related lists in tabular format. My code for it goes as below.

Visualforce Page:

<apex:page controller="Report" showHeader="{!bolPrintableView}" sidebar="{!bolPrintableView}" action="{!init}"> 
<head>
    <style type="text/css" media="print">
         @page { size: landscape; }
    </style>
</head>
<body>
    <div style="text-align: center">
    <apex:outputPanel rendered="{!NOT(bolPrintableView)}" styleClass="buttonStyle" style="background:LightBlue;width:150px;height:40px;">
        <a href="/apex/samc_Risk_Recom?print=1" target="_blank">Printable View</a>
    </apex:outputPanel>
    </div>

    <apex:outputPanel rendered="{!bolPrintableView}">
        <script>
          window.print()
        </script>
    </apex:outputPanel>

    <apex:form >
        <apex:outputLabel value="File  :  " for="Filename" styleClass="container" style="text-align: center;width:150px;height:40px;"/>
        <apex:selectList multiselect="false" value="{!filter}" label="FileName" size="1" id="Filename">
          <apex:selectOption itemValue="Select" itemLabel="--Select--"/>
          <apex:selectOption itemValue="1F" itemLabel="1A"/>
          <apex:selectOption itemValue="2C" itemLabel="2B"/>
          <apex:selectOption itemValue="2E" itemLabel="3C"/>
  <apex:actionSupport event="onchange" rerender="wrapper" action="{!getresult}" status="status"/>
</apex:selectList>

<apex:actionStatus id="status">
  <apex:facet name="start">
    <div>Loading Please wait........</div>
  </apex:facet>
</apex:actionStatus>


    <apex:pageBlock title="Actions Report">
    <apex:outputPanel layout="none" id="wrapper">
        <apex:repeat value="{!Customer}" var="a">
            <apex:pageBlock title="{!a.Custome_Name2__c}">
                <apex:pageBlockSection columns="8">
                    <apex:pageBlockTable value="{!a}" var="a" columns="6" columnsWidth="100px,80px,80px,120px,60px,60px" id="pgbtable">
                        <apex:facet name="header">Customer Details</apex:facet>
                            <apex:column headerValue="CustomerID">
                                <apex:outputText value="{!RIGHT(a.Name,9)} "></apex:outputText>
                            </apex:column>
                            <apex:column headerValue="ProjectID">
                                <apex:outputText value="{!RIGHT(a.Ext_Project_ID__c,8)}"></apex:outputText>
                            </apex:column>
                            <apex:column value="{!a.Customer_Name2__c}"/>
                    </apex:pageBlockTable>  

                    <apex:pageBlockTable value="{!a.Projects__r}" var="c" columns="1" columnsWidth="60px">
                        <apex:facet name="header">Projects</apex:facet>
                            <apex:column value="{!c.Projects_Friendly__c}"/>
                    </apex:pageBlockTable>  

                    <apex:pageBlockTable value="{!a.ActionsTobe_Imp__r}" var="d" columns="1" columnsWidth="60px">
                        <apex:facet name="header">Actions to be Implemented</apex:facet>
                            <apex:column value="{!d.Recommendation__c}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:repeat>
        </apex:outputPanel>
    </apex:pageBlock>
    </apex:form>
</body>

Controller:

public class Report
{   
    public Boolean bolPrintableView {get;set;}

    public String filter{get; set;}

    public String getProfile() {
        Id profileId=userinfo.getProfileId();
        String profileName=[Select Id,Name from Profile where Id=:profileId].Name;
        return profileName;
    }

    public void init() {
        String strPrintableView = ApexPages.currentPage().getParameters().get('print');
        bolPrintableView = (strPrintableView == '1');
    }

    public List < Customer__c > Cust {
        get;
        set;
    }

    public Report()
    {
       String pName = getProfile();
      if(('System Administrator'.equals(pName))||('Project TEST'.equals(pName))){ 
      cust = [SELECT Name,Ext_Project_ID__c,Customer_Name2__c,FileNum__c
                      (SELECT Projects_Friendly__c FROM Projects__r limit 5),
                      (SELECT Recommendation__c FROM ActionsTobe_Imp__r) FROM Customer__c where AND Days_since__c = 10 AND Client_ID__c = 'ABC' AND Show__c = TRUE];
        }
        else{
            return;
        }

    }   

     public void getresult() {

         String pName = getProfile();
         if(('System Administrator'.equals(pName))||('Project TEST'.equals(pName))){
              if(filter.equalsIgnoreCase('select')){
                    cust = [SELECT Name,Ext_Project_ID__c,Customer_Name2__c,FileNum__c
                      (SELECT Projects_Friendly__c FROM Projects__r limit 5),
                      (SELECT Recommendation__c FROM ActionsTobe_Imp__r) FROM Customer__c where AND Days_since__c = 10 AND Client_ID__c = 'ABC' AND Show__c = TRUE];
              }

              else if(filter.equalsIgnoreCase('1A')) {

                  cust = [SELECT Name,Ext_Project_ID__c,Customer_Name2__c,FileNum__c
                      (SELECT Projects_Friendly__c FROM Projects__r limit 5),
                      (SELECT Recommendation__c FROM ActionsTobe_Imp__r) FROM Customer__c where AND Days_since__c = 10 AND Client_ID__c = 'ABC' AND Show__c = TRUE AND FileNum__c >= 1118 AND FileNum__c  <= 1128];
              }

               else if(filter.equalsIgnoreCase('2C')) {
                   }

              else if(filter.equalsIgnoreCase('2E')) {

              }
         }   
    }
}

But am unable to rerender the pageblock by filtering with picklist with the above code. In my debug logs i could see the result obtained from my Query in controller.

2
  • can put only relevant code regarding your issues Jun 22, 2017 at 19:57
  • Could anybody please take a look at the code?
    – user43192
    Jul 6, 2017 at 14:25

1 Answer 1

0

can i know where am i making wrong in the code?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .