You need to sign in to do that
Don't have an account?
RAMANJINEYULU GOGULA
how to put wrapper class(multiple object) fields side by side
I want to keep 4 coloumns as Name, PhoneNumber, OrderName(oName), PaymentAmount.
Controller:
public class multiwrapper
{
public class multiInfo
{
public String Name {get;set;}
public String phNum {get;set;}
public String oName {get;set;}
public Decimal payment{get;set;}
}
public List<multiInfo> aldata{get;set;}
public multiwrapper()
{
aldata = new List<multiInfo>();
multiInfo mi;
for(PersonInfo__c pi:[SELECT Name,Phone_Number__c FROM PersonInfo__c])
{
mi=new multiInfo();
mi.Name = pi.Name;
mi.phNum = pi.Phone_Number__c;
aldata.add(mi);
}
for(Order__c oc:[SELECT Name,Payment_Amount__c FROM Order__c])
{
mi=new multiInfo();
mi.oName = oc.Name;
mi.payment = oc.Payment_Amount__c;
aldata.add(mi);
}
}
}
VF Page:
<apex:page sidebar="false" controller="multiwrapper" standardStylesheets="false">
<style>
h1
{
background-color:pink;font-size:44px;font-family:Mistral;
}
</style>
<center>
<h1>Multi-Object Wrapper</h1>
</center>
<table>
<tr>
<th>Name</th>
<th>Phone Number</th>
<th>Order Name</th>
<th>Payment Amount</th>
</tr>
<apex:repeat value="{!aldata}" var="dat">
<tr>
<td><apex:outputText value="{!dat.Name}"></apex:outputText></td>
<td><apex:outputText value="{!dat.phNum}"></apex:outputText></td>
<td><apex:outputText value=" {!dat.oName}"></apex:outputText></td>
<td><apex:outputText value=" {!dat.payment}"></apex:outputText></td>
</tr>
</apex:repeat>
</table>
</apex:page>
Controller:
public class multiwrapper
{
public class multiInfo
{
public String Name {get;set;}
public String phNum {get;set;}
public String oName {get;set;}
public Decimal payment{get;set;}
}
public List<multiInfo> aldata{get;set;}
public multiwrapper()
{
aldata = new List<multiInfo>();
multiInfo mi;
for(PersonInfo__c pi:[SELECT Name,Phone_Number__c FROM PersonInfo__c])
{
mi=new multiInfo();
mi.Name = pi.Name;
mi.phNum = pi.Phone_Number__c;
aldata.add(mi);
}
for(Order__c oc:[SELECT Name,Payment_Amount__c FROM Order__c])
{
mi=new multiInfo();
mi.oName = oc.Name;
mi.payment = oc.Payment_Amount__c;
aldata.add(mi);
}
}
}
VF Page:
<apex:page sidebar="false" controller="multiwrapper" standardStylesheets="false">
<style>
h1
{
background-color:pink;font-size:44px;font-family:Mistral;
}
</style>
<center>
<h1>Multi-Object Wrapper</h1>
</center>
<table>
<tr>
<th>Name</th>
<th>Phone Number</th>
<th>Order Name</th>
<th>Payment Amount</th>
</tr>
<apex:repeat value="{!aldata}" var="dat">
<tr>
<td><apex:outputText value="{!dat.Name}"></apex:outputText></td>
<td><apex:outputText value="{!dat.phNum}"></apex:outputText></td>
<td><apex:outputText value=" {!dat.oName}"></apex:outputText></td>
<td><apex:outputText value=" {!dat.payment}"></apex:outputText></td>
</tr>
</apex:repeat>
</table>
</apex:page>
Please refer below links for similar discussion.
http://salesforce.stackexchange.com/questions/23856/create-one-table-of-multiple-object-types
http://stackoverflow.com/questions/8157240/combine-multiple-objects-within-a-list
https://developer.salesforce.com/forums/ForumsMain?id=906F000000091yJIAQ
http://salesforce.stackexchange.com/questions/36960/to-display-two-fields-from-two-different-objects-in-a-single-column-of-a-table
Hope this helps you!
Please mark it as solved if this helps you.so that it will make available for others as a proper solution.
Thanks and Regards
Sandhya