Show Opp and OPL
public class myOppwithOppLineItem {
public boolean isCheck{get;set;}
public String getOpp() {
return null;
}
public List<Opportunity> lstOpp{get;set;}
public List<wrapperClass> lstwrapperClass {get;set;}
public class wrapperClass{
public string OpportunityName {get;set;}
// public boolean isCheck{get;set;}
public List<wrapperChild> lstopli {get;set;}
public wrapperClass(string OppName){
this.OpportunityName = OppName ;
lstopli = new List<wrapperChild>();
}
}
public class wrapperChild{
public OpportunityLineItem opplI {get;set;}
public wrapperChild(OpportunityLineItem opli){
this.opplI = opli;
}
}
Map<string,wrapperClass> mapOppNameClass = new Map<string,wrapperClass>();
public myOppwithOppLineItem (){
lstwrapperClass = new List<wrapperClass>();
Map<Id,Opportunity> mapidOpportunity = new map<id,Opportunity>([select Id,Name from Opportunity]);
set<id> sid = new set<id>();
List<OpportunityLineItem> lstOppLi = [select Id,Opportunity.Name,Opportunity.id,ServiceDate,Description,PriceBookEntry.Product2.Name,PriceBookEntry.Product2.ProductCode,Quantity,UnitPrice,TotalPrice from OpportunityLineItem where OpportunityId in :mapidOpportunity .keyset()];
Map<Id,List<OpportunityLineitem>> mapIdOpli = new Map<id,List<OpportunityLineitem>>();
for(OpportunityLineItem opli :lstOppLi){
if(mapIdOpli.get(opli.opportunity.id)==null){
mapIdOpli.put(opli.opportunity.id, new List<OpportunityLineItem>());
}mapIdOpli.get(opli.opportunity.id).add(opli);
}
for(Id i :mapIdOpli.keyset()){
Opportunity opp = mapidOpportunity.get(i);
wrapperClass w = new wrapperClass(opp.Name);
List<OpportunityLineItem> opli = mapIdOpli.get(i);
for(OpportunityLineItem opl :opli){
wrapperChild w1 = new wrapperChild(opl);
w.lstopli.add(w1);
}
lstwrapperClass.add(w);
}
}
}
<apex:page controller="myOppwithOppLineItem">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons ><apex:commandButton value="Click Me"/></apex:pageBlockButtons>
<apex:repeat value="{!lstwrapperClass}" var="varOpp">
<apex:outputText value="{!varOpp.OpportunityName}">
<apex:inputCheckbox value="{!isCheck}"/>
</apex:outputText>
<apex:pageBlockTable value="{!varOpp.lstopli}" var="x">
<apex:column value="{!x.opplI.ServiceDate}"/>
<apex:column value="{!x.opplI.Description}"/>
<apex:column value="{!x.opplI.PriceBookEntry.Product2.Name}"/>
<apex:column value="{!x.opplI.PriceBookEntry.Product2.ProductCode}"/>
<apex:column value="{!x.opplI.Quantity}"/>
<apex:column value="{!x.opplI.UnitPrice}"/>
</apex:pageBlockTable>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
public boolean isCheck{get;set;}
public String getOpp() {
return null;
}
public List<Opportunity> lstOpp{get;set;}
public List<wrapperClass> lstwrapperClass {get;set;}
public class wrapperClass{
public string OpportunityName {get;set;}
// public boolean isCheck{get;set;}
public List<wrapperChild> lstopli {get;set;}
public wrapperClass(string OppName){
this.OpportunityName = OppName ;
lstopli = new List<wrapperChild>();
}
}
public class wrapperChild{
public OpportunityLineItem opplI {get;set;}
public wrapperChild(OpportunityLineItem opli){
this.opplI = opli;
}
}
Map<string,wrapperClass> mapOppNameClass = new Map<string,wrapperClass>();
public myOppwithOppLineItem (){
lstwrapperClass = new List<wrapperClass>();
Map<Id,Opportunity> mapidOpportunity = new map<id,Opportunity>([select Id,Name from Opportunity]);
set<id> sid = new set<id>();
List<OpportunityLineItem> lstOppLi = [select Id,Opportunity.Name,Opportunity.id,ServiceDate,Description,PriceBookEntry.Product2.Name,PriceBookEntry.Product2.ProductCode,Quantity,UnitPrice,TotalPrice from OpportunityLineItem where OpportunityId in :mapidOpportunity .keyset()];
Map<Id,List<OpportunityLineitem>> mapIdOpli = new Map<id,List<OpportunityLineitem>>();
for(OpportunityLineItem opli :lstOppLi){
if(mapIdOpli.get(opli.opportunity.id)==null){
mapIdOpli.put(opli.opportunity.id, new List<OpportunityLineItem>());
}mapIdOpli.get(opli.opportunity.id).add(opli);
}
for(Id i :mapIdOpli.keyset()){
Opportunity opp = mapidOpportunity.get(i);
wrapperClass w = new wrapperClass(opp.Name);
List<OpportunityLineItem> opli = mapIdOpli.get(i);
for(OpportunityLineItem opl :opli){
wrapperChild w1 = new wrapperChild(opl);
w.lstopli.add(w1);
}
lstwrapperClass.add(w);
}
}
}
<apex:page controller="myOppwithOppLineItem">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons ><apex:commandButton value="Click Me"/></apex:pageBlockButtons>
<apex:repeat value="{!lstwrapperClass}" var="varOpp">
<apex:outputText value="{!varOpp.OpportunityName}">
<apex:inputCheckbox value="{!isCheck}"/>
</apex:outputText>
<apex:pageBlockTable value="{!varOpp.lstopli}" var="x">
<apex:column value="{!x.opplI.ServiceDate}"/>
<apex:column value="{!x.opplI.Description}"/>
<apex:column value="{!x.opplI.PriceBookEntry.Product2.Name}"/>
<apex:column value="{!x.opplI.PriceBookEntry.Product2.ProductCode}"/>
<apex:column value="{!x.opplI.Quantity}"/>
<apex:column value="{!x.opplI.UnitPrice}"/>
</apex:pageBlockTable>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
Comments
Post a Comment