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
suneilchetlursuneilchetlur 

Values in a columns instead of rows in visualforce page

Hi Ther,

 

I am trying to build a visualforce page which is rendered when a custom button on an opportunity page is clicked.

 The idea of the VF page is to have a table which lists all the opportunitylineitems(products) and opportunitylineitemschedules(quantity fiield).

I have been able to create this table in VF and have been able to succesfully show the lineitems and schedule quantity values in the page.However,what is happening now is that suppose an opportunitylineitem(product) contains three schedules,in the page i am getting three rows with product name and schedule quantity.What i want is that alongside this particular lineitem i should have these three lineitemschedule quantities in three columns in a single row instead of three rows.

 

Any help would be highly appreciated as this is an urgent requirement i have.Here's the controller code and VF page:

 

 

 

 

 

 

 

 

 

 

<apex:page standardController="opportunity" tabStyle="opportunity" extensions="mySecondController"> <apex:form > <apex:pageBlock title="opp line items" mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons location="top" > <apex:commandButton value="Save" action="{!saveChanges}" rerender="main" status="ajaxStatus"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:actionStatus id="ajaxStatus" startText="Updating line items..."> </apex:actionStatus> <apex:pageBlockTable value="{!mySecondController}" var="oli" columns="8"> <apex:column headerValue="Name"> {!oli.transcript.PriceBookEntry.Product2.Name} </apex:column> <apex:column > <apex:facet name="header"><b>QUARTER</b></apex:facet> <apex:inputField value="{!oli.trainee.quantity}"/> </apex:column> <!--</apex:panelgrid>--> <!-- <apex:column headerValue="Quarter2" footervalue="{!oli.Quantity}"> <apex:inputField value="{!oli.Quantity}"/> </apex:column> <apex:column headerValue="Quarter3" footervalue="{!oli.Quantity}"> <apex:inputField value="{!oli.Quantity}"/> </apex:column> <!--<apex:column headerValue="Quarter4" footervalue="{!oli.Quantity}"> <apex:inputField value="{!oli.Quantity}"/> </apex:column>--> <apex:column headerValue="Sum of Products per quarter"> {!oli.transcript.Quantity} </apex:column> <apex:column headerValue="Quantity" footervalue="{!total.quantity}"> <apex:inputField value="{!oli.transcript.quantity}"/> </apex:column> <apex:column headerValue="Sales Price" > <apex:inputField value="{!oli.transcript.UnitPrice}"/> </apex:column> <apex:column headerValue="LineDesc" > <apex:inputField value="{!oli.transcript.description}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

public class mySecondController { opportunity proj; opportunity []proj1; opportunitylineitem []oppli; opportunitylineitemschedule []o12; public opportunity tp { get; set; } public opportunitylineitem transcript { get; set; } public opportunitylineitemschedule trainee { get; set; } public mySecondController(opportunity tp1, opportunitylineitem trans1,opportunitylineitemschedule p) { tp = tp1; transcript = trans1; trainee = p; } public Opportunitylineitem total { get; private set; } public Opportunitylineitemschedule quart { get; private set; } public class myexception extends exception{} list<mySecondController> result=new list<mySecondController>(); list<mySecondController> result1=new list<mySecondController>(); public mySecondController(ApexPages.StandardController controller){ myexception e=new myexception('wromg feed'); this.proj = (opportunity)controller.getSubject(); proj1=[select id,amount_type__c from opportunity where id=:this.proj.id]; this.oppli=[select quantity,opportunityid,Id,PriceBookEntry.Product2.Name,UnitPrice,Description, PricebookEntryId from opportunitylineitem where opportunityid =:this.proj.id]; list<id>b=new list<id>(); for(opportunitylineitem o1235:this.oppli) b.add(o1235.id); this.o12 =[select scheduledate,quantity,id,opportunitylineitemid from opportunitylineitemschedule where opportunitylineitemid in:b]; this.total = new Opportunitylineitem(quantity = 0); this.quart=new opportunitylineitemschedule(quantity =0); list<id>list1=new list<id>(); try{ for(opportunity opportun:this.proj1){ if(opportun.amount_type__c=='One Time - Auto - Monthly'){ opportunitylineitem curTrans; for(Opportunitylineitem o3:this.oppli) { curTrans= o3; if((o3.quantity != null)) { total.quantity += o3.quantity; } opportunitylineitemschedule []olis10=[select scheduledate,quantity,id,opportunitylineitemid from opportunitylineitemschedule where opportunitylineitemid =:o3.id]; opportunitylineitemschedule curTrainingPath; list<opportunitylineitemschedule> li =new list<opportunitylineitemschedule>(); for(opportunitylineitemschedule olis:this.o12){ if(olis.opportunitylineitemid ==curTrans.id ){ curTrainingPath=olis; result.add(new mySecondController(opportun,curTrans,curTrainingPath)); } } } } } } catch(exception e1) { system.debug('<<<<<'+e1); } } public mySecondController[] getmySecondController() { return result; } public opportunitylineitem getol(){ return this.total; } public opportunitylineitemschedule get1ols() { return this.quart; } // Action Method called from page button public pagereference saveChanges() { upsert this.oppli; upsert this.o12; PageReference oppPage = new ApexPages.StandardController(this.proj).view(); oppPage.setRedirect(true); return oppPage; return null; } public opportunity getOpp() { return [select id, name,amount_type__c, (select id,PriceBookEntry.Product2.Name,Quantity,UnitPrice,Description,PricebookEntryId from OpportunityLineItems limit 5) from opportunity where id =:System.currentPageReference().getParameters().get('id')]; } }

 

 

Regards,

Suneil

BeeddiskShahBeeddiskShah

 Try this method,  I am pretty sure it will work.

 

Create an innerclass of object type Opportunityid, List of Schedules, List of line items. Then in contructor query every table and then populate the inner class with the appropriate fields.

 

Then create a list of the new object (innerclass) and bind it with data table. I used this approach to create a dynamic columns.

 

Let me know the outcome.

 

Cheers,

Sid

Techno-functional Consultant,

Salesforce.com

http://force.siddheshkabe.co.in

 

 

suneilchetlursuneilchetlur

Hey Sid,

 

I didn't quite understand how to do the innerclass bit.can you please tell me the basic outline frame of the change that i need to do in the controller or a small example skeleton of how to go abt this.

 

Regards,

suneil

suneilchetlursuneilchetlur

Hi

i tried to do what you told me...heres the code...but i was not able to bind it with the datatable as it threw an error saying visualforcearraylist.newclass is unknown property

How should i proceed further, now that i have done pretty much what u had advised...is there something wrong with what i am doing here?

public class mySecondController { public class secondcontroller{ opportunity [] tp1 ; opportunitylineitem []transcript1; opportunitylineitemschedule []trainee1; list<SecondController> result2=new list<SecondController>(); public opportunity tp2 { get; set; } public opportunitylineitem []transcript2 { get; set; } public opportunitylineitemschedule []trainee2 { get; set; } public SecondController(opportunity t1, list<opportunitylineitem> tran1,list<opportunitylineitemschedule> p1) { tp2 = t1; transcript2 = tran1; trainee2 = p1; } public SecondController(ApexPages.StandardController controller) { tp1=[select id, name,amount_type__c, (select id,PriceBookEntry.Product2.Name,Quantity,UnitPrice,Description,PricebookEntryId from OpportunityLineItems limit 5) from opportunity where id =:System.currentPageReference().getParameters().get('id')]; this.transcript1 =[select quantity,opportunityid,Id,PriceBookEntry.Product2.Name,UnitPrice,Description, PricebookEntryId from opportunitylineitem where opportunityid =:System.currentPageReference().getParameters().get('id')]; list<id>b1=new list<id>(); for(opportunitylineitem o1235:this.transcript1 ) b1.add(o1235.id); this.trainee1 =[select scheduledate,quantity,id,opportunitylineitemid from opportunitylineitemschedule where opportunitylineitemid in:b1]; for(opportunity opportun:this.tp1){ if(opportun.amount_type__c=='One Time - Auto - Monthly'){ opportunitylineitem curTrans; list<opportunitylineitem> lio =new list<opportunitylineitem>(); list<opportunitylineitemschedule> li =new list<opportunitylineitemschedule>(); for(Opportunitylineitem o3:this.transcript1) { curTrans= o3; // if((o3.quantity != null)) { // total.quantity += o3.quantity; // } opportunitylineitemschedule curTrainingPath; for(opportunitylineitemschedule olis:this.trainee1){ if(olis.opportunitylineitemid ==curTrans.id ){ curTrainingPath=olis; li.add(curTrainingPath); } } lio.add(curTrans); } result2.add(new SecondController(opportun,lio,li)); } } } } ..... remaining same as previous

regards,

Suneil

Cool_DevloperCool_Devloper

Mr Suniel,

 

Your code is not at all readable!!

 

Cool_D