You need to sign in to do that
Don't have an account?

Showing records in pageblock table in an proper order by a unique names
Hello Everyone,
Iam showing records in an pageblock table by using wrapper class.

In the above image, showing records in an table. left hand side products are parent object records and right side records are child object product feature records. For a single parent record i have to show all the associated childs in rightside column but currently in table, product is repeatly coming with every product feature.
Actually it has to show one "Diesel Generator" in right side and "Black Colour","Brown Colour" features has to show in right side, mainly it has to show in one block. i.e, resultly it has to show like in the below image.
vf code:
<apex:pageBlockTable value="{!selectedPrdctsWithFeatures}" var="spf">
<apex:column value="{!spf.selectedProdctname}" headerValue="Product"/>
<apex:column headerValue="Product Features">
<table border="1">
<tr> <th><b>Select</b></th>
<th><b>Colour</b></th>
<th><b>Engine Capacity</b></th>
</tr>
<tr>
<td width="30%">
<apex:inputCheckbox value="{!spf.selectfeature}"/>
</td>
<td align="center">
<apex:outputText value="{!spf.pftr.Product_Colour__c}"/>
</td>
<td align="center">
<apex:outputText value="{!spf.pftr.Engine_Capacity__c}"/>
</td>
</tr>
</table>
</apex:column>
</apex:pageBlockTable>
Class::
for(Product_Feature__c pf: [select id,Product_Colour__c,Engine_Capacity__c,Product__r.Name,Product__r.Product_Code__c,Product__c from Product_Feature__c where Product__c IN:cstmprdctMap.keyset()]){
selectedPrdctsWithFeatures.add(new CPQsubWrapper(pf.Product__r.Name,pf.Product__r.Product_Code__c,false,pf,null,null,null,null,null,null));
}
Please update me where can i change the logic to show my records as in second image.
Iam showing records in an pageblock table by using wrapper class.
In the above image, showing records in an table. left hand side products are parent object records and right side records are child object product feature records. For a single parent record i have to show all the associated childs in rightside column but currently in table, product is repeatly coming with every product feature.
Actually it has to show one "Diesel Generator" in right side and "Black Colour","Brown Colour" features has to show in right side, mainly it has to show in one block. i.e, resultly it has to show like in the below image.
vf code:
<apex:pageBlockTable value="{!selectedPrdctsWithFeatures}" var="spf">
<apex:column value="{!spf.selectedProdctname}" headerValue="Product"/>
<apex:column headerValue="Product Features">
<table border="1">
<tr> <th><b>Select</b></th>
<th><b>Colour</b></th>
<th><b>Engine Capacity</b></th>
</tr>
<tr>
<td width="30%">
<apex:inputCheckbox value="{!spf.selectfeature}"/>
</td>
<td align="center">
<apex:outputText value="{!spf.pftr.Product_Colour__c}"/>
</td>
<td align="center">
<apex:outputText value="{!spf.pftr.Engine_Capacity__c}"/>
</td>
</tr>
</table>
</apex:column>
</apex:pageBlockTable>
Class::
for(Product_Feature__c pf: [select id,Product_Colour__c,Engine_Capacity__c,Product__r.Name,Product__r.Product_Code__c,Product__c from Product_Feature__c where Product__c IN:cstmprdctMap.keyset()]){
selectedPrdctsWithFeatures.add(new CPQsubWrapper(pf.Product__r.Name,pf.Product__r.Product_Code__c,false,pf,null,null,null,null,null,null));
}
Please update me where can i change the logic to show my records as in second image.
Can you please use following code and try to check if this is giving you the expected output. Please correct the mistakes related to typo or syntax if any:
Thank you so much for your response but actually i'm using one wrapper class instead of two classes which you sent. I have only one wrapper class i.e,
public class CPQsubWrapper{
public string selectedProdctname{get;set;}
public string prdctCode{get;set;}
public Boolean selectfeature{get;set;}
public Product_Feature__c pftr{get;set;}
public Integer qnty{get;set;}
public string couponCode{get;set;}
public Decimal discnt{get;set;}
public Decimal actualPrice{get;set;}
public Decimal listPrice{get;set;}
public Integer totalAmount{get;set;}
public CPQsubWrapper(string sp, string sprdid, Boolean sfr, Product_Feature__c pr, Integer q, string cc, Decimal ds, Decimal ap, Decimal lp, Integer ta){
this.selectedProdctname=sp;
this.prdctCode=sprdid;
this.selectfeature=sfr;
this.pftr=pr;
this.qnty=q;
this.couponCode=cc;
this.discnt=ds;
this.actualPrice=ap;
this.listPrice=lp;
this.totalAmount=ta;
}
}
So if you don't mind can you check with this, how can i with this class???
Thanks in advance :)