Skip to content

Instantly share code, notes, and snippets.

@davidejones
Last active November 6, 2015 19:28
Show Gist options
  • Save davidejones/aa9326c47ef4995f54fc to your computer and use it in GitHub Desktop.
Save davidejones/aa9326c47ef4995f54fc to your computer and use it in GitHub Desktop.
basic test angular datatables in vinsuite
var app = angular.module("omsApp", ['datatables',...other modules here...]);
<div ng-controller="testController">
<h1>here</h1>
<div class="table-header">Data Table Test</div>
<div class="table-responsive">
<div role="grid" class="dataTables_wrapper">
<table datatable="ng" dt-options="dtOptions" dt-column-defs="dtColumnDefs" class="row-border hover table table-striped table-bordered table-hover dataTable">
<thead>
<tr>
<th>ID</th>
<th>FirstName</th>
<th>LastName</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in persons">
<td>{{ person.id }}</td>
<td>{{ person.firstName }}</td>
<td>{{ person.lastName }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<cfscript>
jsonsettingstring = '[
{
....
"wineries_store_orders2": {
"javascript":[
"#JS_URL#angular/angular.min.js",
"#JS_URL#angular/angular-datatables.min.js",
"#JS_URL#jquery-ui.js",
....
]
},
....
}
];
</cfscript>
var uiControlModule = angular.module('uiControlModule',['memberModule','datatables']);
uiControlModule.controller('testController', ['$rootScope', '$scope', 'DTOptionsBuilder', 'DTColumnDefBuilder', function($rootScope, $scope, DTOptionsBuilder, DTColumnDefBuilder) {
var vm = this;
$scope.persons = [
{id:1, firstName:'David', lastName:'Jones'},
{id:2, firstName:'Michael', lastName:'Whetton'},
{id:3, firstName:'Trevor', lastName:'Veralrud'},
{id:4, firstName:'Jeffrey', lastName:'Barron'},
];
$scope.dtOptions = DTOptionsBuilder.newOptions().withPaginationType('full_numbers').withDisplayLength(2);
$scope.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0),
DTColumnDefBuilder.newColumnDef(1).notVisible(),
DTColumnDefBuilder.newColumnDef(2).notSortable()
];
/*
//instead of hardcoded we can load from json feed
$resource('data.json').query().$promise.then(function(persons) {
$scope.persons = persons;
});
*/
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment