function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JHAJHA 

Dynamic Column Display during runtime.

 Hi there!

 

I have a entry form containing

 

customer Name      lookup relationship

item name              lookup relationship

month                    combo having month frm jan to dec

forecast qty            text field

 

i made some entries and then created UI page with following code:

 

<apex:page standardController="Forecast_Entry__c" extensions="ForecastEntryExtension" > <h1>Sales Forecast</h1> <apex:pageBlock > <apex:pageBlockSection title="Forecast Records"> <apex:dataTable value="{!ForecastRecords}" var="Forecastentry" styleClass="list"> <apex:column > <apex:facet name="header">Customer Name</apex:facet> <apex:outputField value="{!Forecastentry.Customer_Name__c}"/> </apex:column> <apex:column > <apex:facet name="header">Item Name</apex:facet> <apex:outputField value="{!Forecastentry.Item_Name__c}"/> </apex:column> <apex:column > <apex:facet name="header">Month</apex:facet> <apex:outputText value="{!Forecastentry.Month__c}"/> </apex:column> <apex:column > <apex:facet name="header">Forecast Qty </apex:facet> <apex:outputText value="{!Forecastentry.Forecast_Qty__c}"/> </apex:column> <apex:column > <apex:facet name="header">Contact Name </apex:facet> <apex:outputField value="{!Forecastentry.Contact__c}"/> </apex:column> </apex:datatable> </apex:pageBlockSection> </apex:pageBlock> <apex:detail ></apex:detail> <apex:detail subject="{!Forecast_Entry__c.Customer_Name__c}" relatedList="false" /> </apex:page>

its displays somewhat like dis :

 

Customer Name      Item Name   Month   Forecast Qty

 

abc                          pqr               jan09      1200

cde                          xyz              jan09       1500

cde                          xyz              feb09       1700

cde                          mno             jan09       2100

efg                           mno            mar09       900

 

 

 But i want to summarize the data based on distinct month horizontally and forecast qty below to it as shown   below:

 

 

Customer Name    Item Name     Jan09          Feb09             Mar09

 abc                         Pqr               1200       

 cde                         xyz               1500          1700

 cde                         mno              2100

 efg                          mno                                                       900

 I want the column header should be dynamic and automatically set as per distinct month available in table data during page display. say here it showing jan09 to mar 09 but sometime it can jan09 to feb09 only or  sometime jan09 to oct09 or sooo on.....

 

 

 

Please help me out.... i will be thankful to u...

 

 

Thanks,

 Jha

Cool_DevloperCool_Devloper

Jha,

You need to set the correct values in the controller and then use a Getter method to return the same to your VF page.

Then on the page, you can set the columns accordingly!!

Cool_D

SJTECH2009SJTECH2009
Use Panel Grid for this.your problem get solved.
SJTECH2009SJTECH2009
<apex:panelGrid columns="1" id="theGrid" width="100%">
                        <table width="100%">
                            <tr>
                                <apex:repeat value="" var="T">
                                      <td  align="center"> 
                                            <apex:outputText value=""/>
                                      </td>
                                      <td width="5%"> 
                                           
                                      </td>     
                                </apex:repeat>
                            </tr>
                        </table>
                </apex:panelGrid>
JHAJHA

Hi SJTECH,

 

 My extension code is below and others in my first posting along with requirement , please let me know where i need to do changes in terms of code.i will be very thankfull to you as its not possible for me to waste anymore days on this,i hve already spend more than a week.... 

 

public with sharing class ForecastEntryExtension { private final Forecast_entry__c forecastentryObj; public ForecastEntryExtension(ApexPages.StandardController controller) { this.forecastentryObj = (forecast_entry__c)controller.getrecord(); } public forecast_entry__c[] getForecastRecords() { /* forecastentryList =[SELECT a.Customer_name__c,a.item_name__c,a.month__c,a.forecast_qty__c, b.Customer_name__c,c.Item_name__c FROM forecast_entry__c a,customer_entry__c b, item_entry__c where a.Customer_name__c= b.Customer_name__c and a.item_name__c=c.Item_name__c ]; */ Forecast_entry__c[] forecastentryList =[SELECT a.Customer_name__c,a.item_name__c, a.month__c,a.forecast_qty__c,a.contact__c FROM forecast_entry__c a]; return forecastentryList; } }

 

 

 

Thanks,

  Jha

JHAJHA

Hi SJTECH2009,

 

I tried this way but not able to get the display properly aligned based on months,moreover is it possible to get the column name on which it is summarized? say here month1,month2,month3 so on....

<apex:page standardController="Forecast_Entry__c" extensions="ForecastEntryExtension" > <apex:repeat value="{!ForecastRecords}" var="fc" > <apexanelGrid columns="5" id="theGrid" columnclasses="left,right" width="100%" border="1"> <table width="100%"> <td align="center"><apex:outputField value="{!fc.Customer_Name__c}"/> </td> <td width="5%"> </td> <td align="center"> <apex:outputField value="{!fc.Item_Name__c}" /> </td> <td width="5%"> </td> <td aling="center"> <apex:outputpanel> <apex:outputText value="{!fc.Forecast_Qty__c}" rendered="{!fc.month__c='Month1'}" style="font-weight:bold;color:red " /> <apex:outputText value=" " rendered="{!fc.month__c='Month1'}" /> </apex:outputpanel> </td> <td width="5%"> </td> <td align="center" > <apex:outputpanel> <apex:outputText value="{!fc.Forecast_Qty__c}" rendered="{!fc.month__c='Month2'}" style="font-weight:bold;color:green " /> <apex:outputText value=" " rendered="{!fc.month__c='Month2'}" /> </apex:outputpanel> </td> <td width="5%"> </td> <td align="center"> <apex:outputpanel> <apex:outputText value="{!fc.Forecast_Qty__c}" rendered="{!fc.month__c='Month3'}" style="font-weight:bold;color:brown" /> <apex:outputText value=" " rendered="{!fc.month__c='Month3'}" /> </apex:outputpanel> </td> <td width="5%"> </td> <td> <apex:outputpanel > <apex:outputText value="{!fc.Forecast_Qty__c}" rendered="{!fc.month__c='Month4'}" style="font-weight:bold;color:pink" /> <apex:outputText value=" " rendered="{!fc.month__c='Month4'}" /> </apex:outputpanel> </td> <td width="5%"> </td> </table> </apexanelGrid> </apex:repeat> </apex:page>

 

Here hows its possible to increase or decrease column during run time as we are already defining <apexutputPanel >  code ( say this can be sometime for 2month or 3month ) based on distinct month entries in forecast table.how it is possible to hard code this initially.

 

I want to render it dynamically,isit possible??

 

Any help will be heartly welcomed....

 

Thanks,

 Jha