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
greenstorkgreenstork 

What's the best strategy for displaying a dataTable of more than 1000 records?

I have a table of "members" that I would like to display on a VF/Sites page.  Unfortunately, there are over 1,300 records in the list.  The ideal solution would be to paginate the results set into lists of 200.  I'm sure that I could figure this out but if anyone has any code samples to start from, that would be ideal and thanks in advance.

 

In the meantime, I've used the following code to pull the full list into my VF page, using two lists in apex, two getters, and two dataTables in VF.  This would work, except that I'm having issues aligning columns.  I've used columnWidths on my dataTables but I can't for the life of me get my columns to line up. Any ideas?

 

 

public with sharing class ONEN_CTRL_MemberList {

List<Membership__c> firstMembers;

List<Membership__c> secondMembers;

Set<Id> firstList = new Set<Id>();

 

public List<Membership__c> getFirstMembers(){

firstMembers = [select Id, Contact__r.Full_Name__c, Contact__r.Account.Name, Contact__r.MailingCity, Contact__r.MailingState, End_Date__c FROM Membership__c WHERE Event__r.Type__c = 'Membership' AND Active__c = 'Yes' ORDER BY Contact__r.LastName LIMIT 1000 ];

 

for (Membership__c member : firstMembers ) {

firstList.add(member.id);

} system.debug('First List' + firstList.size()

);

return firstMembers; }

 

public List<Membership__c> getSecondMembers(){

secondMembers = [select Contact__r.Full_Name__c, Contact__r.Account.Name, Contact__r.MailingCity, Contact__r.MailingState, End_Date__c FROM Membership__c WHERE Event__r.Type__c = 'Membership' AND Active__c = 'Yes' AND Id NOT IN :firstList ORDER BY Contact__r.LastName LIMIT 1000 ];

return secondMembers;

}

}

 

 And the VF page: 

 

 

<apex:page controller="ONEN_CTRL_MemberList" showHeader="false">

<apex:stylesheet value="http://www.cascadiagbc.org/portal_css/CascadiaTheme/ploneStyles7101.css" />

 

<apex:dataTable value="{!firstMembers}" var="members" id="theTable" rowClasses="odd,even" style="width:420px" cellpadding="5" columnsWidth="90, 170, 60, 60, 40">

<apex:column >

<apex:facet name="header">Name</apex:facet>

<apex:outputText value="{!members.Contact__r.Full_Name__c}"/>

</apex:column> <apex:column >

<apex:facet name="header">Organization</apex:facet>

<apex:outputText value="{!members.Contact__r.Account.Name}"/>

</apex:column>

<apex:column >

<apex:facet name="header">City</apex:facet>

<apex:outputText value="{!members.Contact__r.MailingCity}"/>

</apex:column>

<apex:column >

<apex:facet name="header">State</apex:facet>

<apex:outputText value="{!members.Contact__r.MailingState}"/>

</apex:column>

<apex:column >

<apex:facet name="header">End Date</apex:facet>

<apex:outputField value="{!members.End_Date__c}"/>

</apex:column>

</apex:dataTable>

<apex:dataTable value="{!secondMembers}" var="members2" id="theTable2" rowClasses="odd,even" style="width:420px" cellpadding="5" columnsWidth="90, 170, 60, 60, 40" >

<apex:column style="width:90px">

<apex:facet name="header">Name</apex:facet>

<apex:outputText value="{!members2.Contact__r.Full_Name__c}"/>

</apex:column>

<!-- etcetera -->  

</apex:dataTable>

</apex:page>

 

And here is a screen shot of the two lists and the differing column width formats:

http://screencast.com/t/2mHaNgyN  

Message Edited by greenstork on 06-29-2009 08:50 AM
mtbclimbermtbclimber

Looks like you just have a single, straight-forward SOQL statement so you should be able to leverage StandardSetController to get your pagination. Check out the Visualforce developer guide section on Standard List Controller as well as the StandardSetController class.

 

Much better to solve for the usable case than the one where there are 1300 records in one page :smileywink:

greenstorkgreenstork
Since this is in a Sites page, I need to iframe this list into a website and I don't want the Salesforce skin. Is it possible to use list controllers with showHeader="false".  I seem to remember some limitation here.
mtbclimbermtbclimber
Page.Showheader="false" should work the same regardless of the controller. Besides you are going to need to instantiate this in your Apex class controller anyway.
GoForceGoGoForceGo

Andrew,

 

I need to show more than 1000 records with the additional challenge that I need to show entries for which NO database record exists. Appreciate your thoughts.

 

http://community.salesforce.com/sforce/board?board.id=Visualforce