Skip to content

Instantly share code, notes, and snippets.

@jenishshingala
Created February 3, 2017 15:44
Show Gist options
  • Save jenishshingala/45d2eb23be7cf09542f2507ad2b55f8c to your computer and use it in GitHub Desktop.
Save jenishshingala/45d2eb23be7cf09542f2507ad2b55f8c to your computer and use it in GitHub Desktop.
Visualforce Page
<apex:page controller="testpagecls" sidebar="false">
<!-- <apex:form>
<apex:pageBlock>
<apex:pageBlockTable value="{!lstOfTest}" var="tst">
<apex:column value="{!tst.id}"/>
<apex:column value="{!tst.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>-->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.8/css/dataTables.bootstrap.min.css"/>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdn.datatables.net/1.10.8/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.8/js/dataTables.bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"/>
<script>
var myApp = angular.module('myApp',[]);
myApp.controller('HomeController',function($scope){
$scope.Variable = {};
$scope.Variable = 'My Angular Table';
$scope.myData = {};
//$scope.myData.items = [ {text : "one"}, {text : "two"}, {text : "three"} ];
var rowdata = '{!testjson}';
$scope.parseddata = JSON.parse(rowdata);
console.log('rowdata-->'+rowdata);
console.log($scope.parseddata);
});
</script>
<body ng-app="myApp" ng-controller="HomeController">
<apex:form >
{{Variable}} <br/><br/>
<table Id="Acctable" class="table table-striped table-bordered table-hover" align="center">
<thead>
<tr>
<th >
id
</th>
<th>
Name
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="var in parseddata">
<td>{{var.Id}}</td>
<td>{{var.Name}}</td>
</tr>
</tbody>
</table>
</apex:form>
<script>
$(document).ready(function() {
$('#Acctable').DataTable();
} );
</script>
</body>
</apex:page>
public class testpagecls {
public List<Test__c> lstOfTest{get;set;}
public string testjson{get;set;}
public testpagecls(){
lstOfTest = [select id,name from Test__c];
lstOfTest.sort();
testjson = json.serialize(lstOfTest);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment