Show Pagination and Colum Sorting on VF page using Jquery Plugin
Requirement: To show Account record in table form on VF page and user able to paginate pages and sort the column:
Solution: Using Jquery Plugin you can directly implement pagination and column Sorting
Download Jquery Plugin : https://sfcomponent-dev-ed.my.salesforce.com/sfc/p/#6F000001f5y8/a/6F0000004XWj/F0czOc51PF5iaC7ERZBb.cO.nU95xWyEaGcUTmPkCaU
Add data table zip file in Static Resource
Class Code:
public class AccountController {
public List<Account> lstofacc{get;Set;}
public AccountController ()
{
lstofacc = new List<Account>([select id,AccountNo, name from account]);
}
}
Page Code:
<apex:page controller="AccountController " sidebar="false" standardStylesheets="false" docType="html-5.0" tabStyle="Account">
<head>
<apex:stylesheet value="{!URLFOR($Resource.DataTable,'DataTable/datatables.min.css')}" />
<apex:stylesheet value="{!URLFOR($Resource.DataTable,'DataTable/jquery.dataTables.css')}" />
<apex:includeScript value="{!URLFOR($Resource.DataTable,'DataTable/datatables.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.DataTable,'DataTable/jquery-1.11.1.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.DataTable,'DataTable/jquery.dataTables.min.js')}"/>
<script>
j$ = jQuery.noConflict();
j$(document).ready( function () {
//var contactTable = j$('[id$="contacttable"]').DataTable();
j$('[id$="contacttable"]').dataTable(
{
"aoColumnDefs": [{
"bSortable": false,
"aTargets": [-1]
}]
}
);
});
</script>
</head>
<body>
<apex:form >
<table id="contacttable" class="display" border="1">
<thead>
<tr>
<th> Account ID</th>
<th> Account No</th>
<th> Account Name</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!lstofacc }" var="objacc">
<tr>
<td><apex:outputField value="{!objacc.Id}"/> </td>
<td><apex:outputField value="{!objacc.accountNumber}"/></td>
<td><apex:outputField value="{!objacc.Name}"/></td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:form>
</body>
</apex:page>
Out Put:
Solution: Using Jquery Plugin you can directly implement pagination and column Sorting
Download Jquery Plugin : https://sfcomponent-dev-ed.my.salesforce.com/sfc/p/#6F000001f5y8/a/6F0000004XWj/F0czOc51PF5iaC7ERZBb.cO.nU95xWyEaGcUTmPkCaU
Add data table zip file in Static Resource
Class Code:
public class AccountController {
public List<Account> lstofacc{get;Set;}
public AccountController ()
{
lstofacc = new List<Account>([select id,AccountNo, name from account]);
}
}
Page Code:
<apex:page controller="AccountController " sidebar="false" standardStylesheets="false" docType="html-5.0" tabStyle="Account">
<head>
<apex:stylesheet value="{!URLFOR($Resource.DataTable,'DataTable/datatables.min.css')}" />
<apex:stylesheet value="{!URLFOR($Resource.DataTable,'DataTable/jquery.dataTables.css')}" />
<apex:includeScript value="{!URLFOR($Resource.DataTable,'DataTable/datatables.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.DataTable,'DataTable/jquery-1.11.1.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.DataTable,'DataTable/jquery.dataTables.min.js')}"/>
<script>
j$ = jQuery.noConflict();
j$(document).ready( function () {
//var contactTable = j$('[id$="contacttable"]').DataTable();
j$('[id$="contacttable"]').dataTable(
{
"aoColumnDefs": [{
"bSortable": false,
"aTargets": [-1]
}]
}
);
});
</script>
</head>
<body>
<apex:form >
<table id="contacttable" class="display" border="1">
<thead>
<tr>
<th> Account ID</th>
<th> Account No</th>
<th> Account Name</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!lstofacc }" var="objacc">
<tr>
<td><apex:outputField value="{!objacc.Id}"/> </td>
<td><apex:outputField value="{!objacc.accountNumber}"/></td>
<td><apex:outputField value="{!objacc.Name}"/></td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:form>
</body>
</apex:page>
Out Put:
Thanks,
Sumit Shukla
sumitshukla.mca@gmail.com
skypeid: shuklasumit1
Casino Tycoon Near Me | Mapyro
ReplyDeleteFind Casino Tycoon near you on Mapyro! Use our list 영천 출장샵 to find the best Casino Tycoon Near Me in 김천 출장샵 New Jersey 경상남도 출장마사지 and find the best casino 부산광역 출장안마 in New 강릉 출장마사지