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
Sfdc11Sfdc11 

pageblocktable...Urgent!!

Hi,

 

Using wrapper class im retriving Account and case details.

I want to disply like this in VF page ,

 

if i use pageblocktable,im getting all data in row from wrapperList..

 

 

hitesh90hitesh90

Hi kavi,

 

You have to use <apex:repeat> to fulfill your requirement.

you can use HTML tags like table,tr,td in your code for designing.
see below link.

apex:repeat

 

Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:- http://mrjavascript.blogspot.in/

pooja@magichorse.compooja@magichorse.com

Hi,

 

Use below example.

 

VF Page:

 

<apex:page controller="caseListController">
    <apex:form>
        <apex:pageBlock>
            <table cellspacing="0" cellpadding="0" width="100%" height="100%" class="list">
                <tr class="headerRow">
                    <th>
                        Case Detail
                    </th>
                    <th>
                        Account Detail
                    </th>
                </tr>
                <apex:repeat value="{!lstCaseList}" var="cs">
                    <tr class="dataRow" onmouseover="if (window.hiOn){hiOn(this);}" onmouseout="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}">
                        <td class="dataCell">
                            {!cs.casedetail.caseNo}
                        </td>
                        <td class="dataCell">
                            {!cs.accountdetail.Name}
                        </td>
                    </tr>
                    <apex:outputPanel rendered="{!if(ISBLANK(cs.casedetail.phone) && ISBLANK(cs.accountdetail.phone),false,true)}">
                        <tr class="dataRow" onmouseover="if (window.hiOn){hiOn(this);}" onmouseout="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}">
                            <td class="dataCell">
                                {!cs.casedetail.phone}
                            </td>
                            <td class="dataCell">
                                {!cs.accountdetail.phone}
                            </td>
                        </tr>
                    </apex:outputPanel>
                </apex:repeat>
            </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

Controller:

 

public class caseListController {
    List<Case> lstCase;
    Public List<CaseList> lstCaseList{get;set;}
    public caseListController(){
        lstCase = [Select id, caseNumber, Contact.Phone, Account.name, Account.phone From case];
        if(lstCase.size()>0){
            lstCaseList = new List<CaseList>();
            for(Case cs:lstCase){
                CaseList obj = new CaseList();
                obj.casedetail = new CaseDetail(cs.caseNumber, cs.Contact.Phone);
                obj.accountDetail = new AccountDetail(cs.Account.name, cs.Account.phone);
                lstCaseList.add(obj);
            }
        }
    }
    Public Class CaseList{
        Public CaseDetail casedetail{get;set;}
        Public AccountDetail accountdetail{get;set;}
        Public CaseList(){
            casedetail = new CaseDetail();
            accountdetail = new accountDetail();
        }
    }
    Public Class CaseDetail{
        Public String caseNo{get;set;}
        Public String phone{get;set;}
        Public CaseDetail(){}
        Public CaseDetail(String caseNo, String phone){
            this.caseNo = caseNo;
            this.phone = phone;
        }
    }
    Public Class AccountDetail{
        Public String name{get;set;}
        Public String phone{get;set;}
        Public AccountDetail(){}
        Public AccountDetail(String name, String phone){
            this.name = name;
            this.phone = phone;
        }
    }
}

 I hope this will help to you.

 

hitesh90hitesh90

Here is the sample example as per your requirement.

 

Visualforce Page:

<apex:page controller="ctrlRepeateruse">
    <apex:pageBlock>
        <apex:pageblockTable value="{!lstwrapperclasstemp}" var="lstwr">
            <apex:column headerValue="Case details">
                <apex:outputLabel value="{!lstwr.objcase.subject}"></apex:outputLabel>
                <br/>
            </apex:column>
            <apex:column headerValue="Case Phone">
                <apex:outputLabel value="{!lstwr.objcase.Contact.phone}"></apex:outputLabel>
            </apex:column>
            <apex:column headerValue="Account details">
                <apex:outputLabel value="{!lstwr.objAcc.Name}"></apex:outputLabel>
                <br/>
            </apex:column>
            <apex:column headerValue="Account Phone">
                <apex:outputLabel value="{!lstwr.objAcc.phone}"></apex:outputLabel>
            </apex:column>
        </apex:pageblockTable>
    </apex:pageBlock>
</apex:page>

 Apex Class:

public class ctrlRepeateruse{
    public List<wrapperclasstemp> lstwrapperclasstemp {get; set;}
    public ctrlRepeateruse(){
        List<Account> lstAcc = [select id,Name,phone from Account limit 2];
        lstwrapperclasstemp = new List<wrapperclasstemp>();
        Case objcase = [select id,subject,contact.phone from case LIMIT 1];
        wrapperclasstemp objwrapperclasstemp;
        for(Account acc: lstAcc){
            objwrapperclasstemp = new wrapperclasstemp();
            objwrapperclasstemp.objAcc = acc;
            objwrapperclasstemp.objcase = objcase;
            lstwrapperclasstemp.add(objwrapperclasstemp);
        }
    }
    
    public class wrapperclasstemp{
        public account objAcc {get; set;}
        public Case objcase {get; set;}
    }
}

 

Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:- http://mrjavascript.blogspot.in/

Sfdc11Sfdc11

Thank you pooja and hitesh..