Created
January 27, 2017 10:52
-
-
Save Sunil02kumar/b520f71660eb2e9dab8b5b17b5a8320c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CollectionLimitController { | |
public List<Account> collectionSizeVariable{get;set;} | |
public String AccountInformationString {get;set;} | |
public CollectionLimitController(){ | |
collectionSizeVariable = new List<Account>(); | |
for(integer i=0;i<50007;i++){ | |
collectionSizeVariable.add(new Account(name='sunil'+i, type='Prospect', Industry='IT')); | |
} | |
datasetForTable dataSet =new datasetForTable(); | |
list<list<String>> dataValues=new list<list<String>>(); | |
list<list<String>> columnsLabels=new list<list<String>>(); | |
columnsLabels.add(new List<String>{'Account name'}); | |
columnsLabels.add(new List<String>{'Type'}); | |
columnsLabels.add(new List<String>{'Industry'}); | |
for(Account sb: collectionSizeVariable){ | |
list<String> fieldvalues = new List<String>(); | |
if(sb.name != null && sb.name != ''){ | |
fieldvalues.add(sb.name ); | |
}else{ | |
fieldvalues.add(''); | |
} | |
if(sb.Type != null && sb.Type != ''){ | |
fieldvalues.add(sb.Type); | |
}else{ | |
fieldvalues.add(''); | |
} | |
if(sb.Industry != null && sb.Industry != ''){ | |
fieldvalues.add(sb.Industry); | |
}else{ | |
fieldvalues.add(''); | |
} | |
dataValues.add(fieldvalues); | |
} | |
dataSet.data = dataValues; | |
dataSet.columns = columnsLabels ; | |
AccountInformationString = JSON.serialize(dataSet); | |
system.debug('************AccountInformationString:'+AccountInformationString); | |
} | |
public class datasetForTable{ | |
public List<List<String>> columns; | |
public List<List<String>> data; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page controller="CollectionLimitController" sidebar="false"> | |
<head> | |
<apex:includescript value="https://code.jquery.com/jquery-1.11.1.min.js" / > | |
<apex:includescript value="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" /> | |
<apex:stylesheet value="https://cdn.datatables.net/1.10.4/css/jquery.dataTables.css" /> | |
<apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" / > | |
<apex:includescript value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" /> | |
<script> | |
var sk= $.noConflict(); | |
var tableData = '{!AccountInformationString}'; | |
//alert('tableData :'+tableData ); | |
sk(document).ready(function() { | |
tableData =tableData .replace(/("\;)/g,"\"") | |
tableData = tableData .replace(/(<\;)/g,'<').replace(/(>\;)/g,'>').replace(/('\;)/g,'\'').replace(/(&\;)/g,'&'); | |
var jsonData = JSON.parse(tableData) | |
//alert('*****jsonData :'+jsonData ); | |
console.log(jsonData); | |
generateTable(JSON.parse(tableData)); | |
}); | |
function generateTable(jsonData){ | |
var tableHeaders=""; | |
$.each(jsonData.columns, function(i, val){ | |
tableHeaders += "<th>" + val + "</th>"; | |
}); | |
$("#tableDiv").empty(); | |
$("#tableDiv").append('<table id="displayTable" class="display" cellspacing="0" width="100%"><thead><tr>' + tableHeaders + '</tr></thead></table>'); | |
$("#displayTable").dataTable(jsonData); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="tableDiv" style="width:100%;overflow: auto;"></div> | |
</body> | |
</apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment