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
BhmBhm 

records in visual force page

Hello,

 

         My requirement is display records in visual force page side by side.

 

for example :

 

                      record1                     record2

                        link                              link

 

                      record3                     record4

                        link                              link

 

                       record5                     record6

                        link                              link

 

 

Here link is a command link or output link. How to display records in visual force page?

 

Any one help me?

 

 

 

MohaMoha

you need to create apex class, which contains a List of Data List<Object__c> and select in a Boucle For all the records here is a code that does this :)

 

<apex:page standardController="Contact"  extensions="DataTableExampleController">
    <head>
      
        <script type="text/javascript" charset="UTF-8">

            $(document).ready( function () {
              var oTable = $('#contacttable').dataTable( {
                  "sDom": 'WRC<"clear">lftip',
                  "bJQueryUI": true,
                  "sPaginationType": "full_numbers",
                  "aoColumnDefs": [ { "bVisible": false, "aTargets": [ ] }],
                  "oColumnFilterWidgets": { "aiExclude": [ 0, 3, 4 ] }
             });
          });

        </script>

    </head>

    <body>

        <h2>Contact Search Demo with jQuery, DataTables, and Visualforce"</h2>
        <h3>Try out the keyword search, show/hide columns, sort, and pagination!</h3>

        <table cellpadding="0" cellspacing="0" border="0" class="display" id="contacttable" style="margin-top:20px;">

            <thead>
             <tr>
                 <th>Name</th>
                 <th>Account</th>
                 <th>Title</th>
                 <th>Phone</th>
                 <th>Email</th>
             </tr>
            </thead>

            <tfoot>
             <tr>
                 <th>Name</th>
                 <th>Account</th>
                 <th>Title</th>
                 <th>Phone</th>
                 <th>Email</th>
             </tr>
            </tfoot>

            <tbody>

                <apex:repeat value="{!Contacts}" var="c">
                    <tr>
                      <td>{!c.Name}</td>
                      <td>{!c.Account.Name}</td>
                      <td>{!c.Title}</td>
                      <td>{!c.Phone}</td>
                      <td>{!c.Email}</td>
                  </tr>
                 </apex:repeat>

            </tbody>

        </table>

    </body>

</apex:page>
            
Apex Class :
public class DataTableExampleController {

    public DataTableExampleController(ApexPages.StandardController controller) {

    }

    private Contact contact;
    public DataTableExampleController(){
        contact = new Contact();
    }
    public ApexPages.StandardSetController contactSet{        
            get{
                if(contactSet == null) {
                    contactSet = new ApexPages.StandardSetController(Database.getQueryLocator(
                                [SELECT Name, Phone, Email, Title, Account.Name FROM Contact]));
            }
            return contactSet;
        }
        set;
    }

    public List<contact> getContacts() {
         return (List<contact>) contactSet.getRecords();
    }
}
Hengky IlawanHengky Ilawan

Hi,

 

Simply use a <apex:panelGrid> will do.

Reference: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_panelGrid.htm

 

<apex:panelGrid columns="2">

	<apex:outputPanel>
		<apex:outputText />
		<apex:outputLink />
	</apex:outputPanel>

</apex:panelGrid>

 

-Hengky-

Varun99Varun99

Hi,

 

 

      Thanks for your reply. But the records will display in this format

 

                   rec1              Link

 

                   rec2               Link

 

                   rec3               Link

 

But using css is it possible how to apply?

 

Thank you

Hengky IlawanHengky Ilawan
Hi,

It might be easier if you can post your code.

-Hengky-
Varun99Varun99

Hi

 

Am displaying my records using apex repeat.

 

<apex:form >
<apex:repeat value="{!reservations}" var="r">
<apex:outputlabel value="{!r.name}"/><br/><br/>
<apex:commandLink action="{!pdfpage}">
<apex:outputtext value="PRINT" styleClass="stybtn"/><br/><br/>
<apex:param name="opid" value="{!r.id}"/>
</apex:commandLink>
</apex:repeat>
</apex:form>

 

 

Thank you

MohaMoha
hello, i've posted a coed for you that answers ur request, the second post
AmitdAmitd

Hi Bhm,

 

one solution to your issue is to create a list of list

You want 2 record in one row

Please use this code as reference 

//APEX CODE

public List<List<Account>> acl{get;set;}

acl = new List<List<Account>>();
List<Account> al;
Integer i=0;
for(account acc: [select id,name from account limit 6]){
if(math.mod(i,2)==0){
al = new List<Account>();
al.add(acc);
}else{
al.add(acc);
acl.add(al);
}
i++;
}

 

//VF PAGE CODE

 

<table cellspacing="5" cellpadding="5" width="50%">
<apex:repeat value="{!acl}" var="a2">
<tr>
<apex:repeat value="{!a2}" var="a3">
<td>{!a3.Id}<br/>{!a3.Name}</td>
</apex:repeat>
</tr>
</apex:repeat>
</table>

 

I hope this answer you question

Please mark it as solved if it works for you.

 

KUDOS

 

Salesforce Developer, Salesforce Administrator