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
westjohnwestjohn 

Which Type of List Passing to VisualForce page?

In Data tables(http://datatables.net/) Which Type of List using to query the records in Apex Controller ?

 

Because I am using Normal List to pass the page datatables told "No records Found".. But I have 5000 records in my List..

 

How can i display my values in page and which type of list will i use?

Best Answer chosen by Admin (Salesforce Developers) 
KapilCKapilC

Hi,

 

I've tried this on my dev org and this is working fine for me. I'm using account standard object to showing records on VF page. Here are the code for that.

 

Controller Class:- 

public class UpperClass{
	public list<Account> lstAccount {get;set;}
	public UpperClass(){
		lstAccount = [Select  Name,TickerSymbol, SLA__c, SLASerialNumber__c, Ownership, 
NumberofLocations__c, NumberOfEmployees From Account where
TickerSymbol != null limit 1000]; } }

 VF Page:-

 

<apex:page controller="UpperClass" showheader="false">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"/>
<apex:includeScript value="http://datatables.net/download/build/jquery.dataTables.nightly.js"/>
<apex:stylesheet value="http://live.datatables.net/media/css/demo_page.css"/>
 <apex:stylesheet value="http://live.datatables.net/media/css/demo_table.css"/>
<script>
$(document).ready(function() {
    $('#example').dataTable();
} );
</script>
<apex:form >
 <table cellspacing="0" cellpadding="0" border="0" id="example" class="display dataTable" aria-describedby="example_info">
    <thead>
        <tr role="row">
            <th aria-label="Name: activate to sort column descending" aria-sort="ascending" style="width: 128px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting_asc">Name</th>
            <th aria-label="TickerSymbol: activate to sort column ascending" style="width: 178px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting">TickerSymbol</th>
            <th aria-label="SLASerialNumber: activate to sort column ascending" style="width: 170px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting">SLASerialNumber</th>
            <th aria-label="Ownership: activate to sort column ascending" style="width: 109px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting">Ownership</th>
            <th aria-label="Number Of Employees: activate to sort column ascending" style="width: 75px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting">Number Of Employees</th>
        </tr>
    </thead>
    
    <tbody aria-relevant="all" aria-live="polite" role="alert">
          <apex:repeat value="{!lstAccount}" var="acc" id="theRepeat">
            <tr class="gradeA odd">
                <td class="  sorting_1">{!acc.name}</td>
                <td class=" ">{!acc.TickerSymbol}</td>
                <td class=" ">{!acc.SLASerialNumber__c}</td>
                <td class=" ">{!acc.Ownership}</td>
                <td class="center ">{!acc.NumberOfEmployees}</td>
            </tr>
        </apex:repeat>        
    </tbody>
 </table>
</apex:form>
</apex:page>

 Result:-

[If you got answer from my post please mark it as solution.]

 

Thanks, Kapil

All Answers

KapilCKapilC

Hi,

 

I've tried this on my dev org and this is working fine for me. I'm using account standard object to showing records on VF page. Here are the code for that.

 

Controller Class:- 

public class UpperClass{
	public list<Account> lstAccount {get;set;}
	public UpperClass(){
		lstAccount = [Select  Name,TickerSymbol, SLA__c, SLASerialNumber__c, Ownership, 
NumberofLocations__c, NumberOfEmployees From Account where
TickerSymbol != null limit 1000]; } }

 VF Page:-

 

<apex:page controller="UpperClass" showheader="false">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"/>
<apex:includeScript value="http://datatables.net/download/build/jquery.dataTables.nightly.js"/>
<apex:stylesheet value="http://live.datatables.net/media/css/demo_page.css"/>
 <apex:stylesheet value="http://live.datatables.net/media/css/demo_table.css"/>
<script>
$(document).ready(function() {
    $('#example').dataTable();
} );
</script>
<apex:form >
 <table cellspacing="0" cellpadding="0" border="0" id="example" class="display dataTable" aria-describedby="example_info">
    <thead>
        <tr role="row">
            <th aria-label="Name: activate to sort column descending" aria-sort="ascending" style="width: 128px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting_asc">Name</th>
            <th aria-label="TickerSymbol: activate to sort column ascending" style="width: 178px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting">TickerSymbol</th>
            <th aria-label="SLASerialNumber: activate to sort column ascending" style="width: 170px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting">SLASerialNumber</th>
            <th aria-label="Ownership: activate to sort column ascending" style="width: 109px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting">Ownership</th>
            <th aria-label="Number Of Employees: activate to sort column ascending" style="width: 75px;" colspan="1" rowspan="1" aria-controls="example" tabindex="0" role="columnheader" class="sorting">Number Of Employees</th>
        </tr>
    </thead>
    
    <tbody aria-relevant="all" aria-live="polite" role="alert">
          <apex:repeat value="{!lstAccount}" var="acc" id="theRepeat">
            <tr class="gradeA odd">
                <td class="  sorting_1">{!acc.name}</td>
                <td class=" ">{!acc.TickerSymbol}</td>
                <td class=" ">{!acc.SLASerialNumber__c}</td>
                <td class=" ">{!acc.Ownership}</td>
                <td class="center ">{!acc.NumberOfEmployees}</td>
            </tr>
        </apex:repeat>        
    </tbody>
 </table>
</apex:form>
</apex:page>

 Result:-

[If you got answer from my post please mark it as solution.]

 

Thanks, Kapil

This was selected as the best answer
westjohnwestjohn

Thanks Kapil..

I have another one doubt in data tables..

 

I am using following type of example in my page..

http://datatables.net/release-datatables/extras/Scroller/large_js_source.html

 

In above example We passed nearly 50000 records to page...

So in My page i have nearly 2,098 records..

I am using Normal list to query the values and passing to page... I got the following error..

When i also performing DML operation in the List..

 

Collection size 2,098 exceeds maximum size of 1,000. 

 

How to pass all records to Page and also How To perform DML operation?