0

I have used paneldgrid to create a table with VF where field values are fetch from the Lead object.

How can I create a custom controller to query the data base and bring field values from the Lead object that will populate the grid cells?

I need to iterate over the Lead object so is it the best way to do this by using a repeat component? (I want to bring the corresponding field values to Status, Name, Phone, and Comments Line 1)

If anyone can help with some code I would really appreciate it!! thanks!!

Here it's the VF code I have so far:

<apex:page StandardController="Lead">
<style>
.colClass{
width:60%;
padding: 5px;
}
.myHeader {
background: #cecece;
font-weight: bold;
}
</style>

<!-- Report Title - Date-->
<apex:panelGrid width="100%" cellpadding="0" cellspacing="0" rules="all">
<apex:outputText value="Title- Date"/> 
</apex:panelGrid>

<!-- The table-->
<apex:panelGrid columns="2" width="100%" cellpadding="0" cellspacing="0" rules="all">

<!-- Status column -->
<apex:outputPanel style="padding:5px;" layout="block" styleClass="myHeader">
<apex:outputText value="Status"/>
</apex:outputPanel>

<!-- Name - Phone column-->
<apex:outputPanel style="padding:5px;" layout="block" styleClass="myHeader">
<apex:outputText value="Name - Phone"/>
</apex:outputPanel> 

<!-- Status field value -->
<apex:outputPanel style="padding:5px;" layout="block">
<apex:outputText value="{!lead.status}"/> 
</apex:outputPanel> 

<!-- Name - Phone field value-->
<apex:outputPanel style="padding:5px;" layout="block">
<apex:panelGrid width="100%" cellpadding="0" cellspacing="0" rules="all">
<apex:outputText value="{!lead.name}"/> 
<apex:outputText value="{!lead.phone}"/> 
</apex:panelGrid> 
</apex:outputPanel>

</apex:panelGrid>

<!-- Comments Lines 1-->

<apex:outputText value="Comments Line 1"/>

</apex:page>
  • sorry code is not found ?Welcome to stackexchange!Could you please post complete code to help with! – Mohith Shrivastava Jul 3 '13 at 16:11
1

A apex:panelGrid will render any apex:repeat elements in a single table cell, and placing apex:panelGrid inside a apex:repeat will render multiple tables. If your goal is one lead per table row, use a apex:dataTable or apex:pageBlockTable. If your goal is several records per row, you'll have to organize your data in the aforementioned tables, perhaps with a wrapper class. apex:panelGrid is designed to lay out non-repeating elements in a HTML table dynamically.

<apex:pageBlockTable value="{!leads}" var="record">
    <apex:column headerValue="Name" value="{!record.Name}"/>
    <apex:column headerValue="Status" value="{!record.status}"/>
    <apex:column headerValue="Email" value="{!record.email}"/>
</apex:pageBlockTable>

The difference between apex:dataTable and apex:pageBlockTable is styling/formatting. The former renders as a normal HTML table, while the other renders in a fashion that looks like a related list (shaded header columns, row highlighting, etc).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.