您好我试图在Altair上使用dataTables。但我似乎可以正确地在我的网页上工作。
继承我的Html视图。
<div class="md-card uk-margin-medium-bottom">
<div class="md-card-content">
<table datatable dt-options="dtOptions" dt-column-defs="dtColumnDefs" class="uk-table" cellspacing="0" width="100%">
<tfoot>
<tr>
<th>Group Name</th>
<th>Last Updated</th>
<th>Schedule</th>
<th>Action</th>
</tr>
</tfoot>
<tbody></tbody>
</table>
</div>
</div>
然后在我的主要路线中添加&#34; Lazy_datatables&#34;
.state("restricted.srdatasource.groups",{
url:"/srdatasource/groups",
templateUrl:'srdatasource/views/datasourceGroupsView.html',
controller: 'datasourceGroupsController',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([
'lazy_parsleyjs',
'lazy_datatables',
'srdatasource/controllers/datasourceGroupsController.js',
'srdatasource/services/datasourceService.js'
]);
}]
},
data: {
pageTitle: 'Groups'
}
})
然后在我的控制器上添加DTOptionsBuilder和DTColumnDefBuilder
$scope.init() = function() {
$scope.all_groups();
}
$scope.all_groups = function() {
DatasourceService.get_dsgroup(function(results){
console.log(results.data)
console.log(this);
// $scope.DSGroupData = results.data;
var vm = this;
vm.dtOptions = DTOptionsBuilder
.fromSource(results.data)
.withPaginationType('full_numbers')
.withColumnFilter({
aoColumns: [
{
type: 'text',
bRegex: true,
bSmart: true
},
{
type: 'number',
bRegex: true,
bSmart: true
},
{
type: 'number',
bRegex: true,
bSmart: true
},
{
type: 'text',
bRegex: true,
bSmart: true
}
]
})
.withOption('initComplete', function() {
$timeout(function() {
$compile($('.dt-uikit .md-input'))($scope);
})
});
vm.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).withTitle('Group Name'),
DTColumnDefBuilder.newColumnDef(1).withTitle('Last Updated'),
DTColumnDefBuilder.newColumnDef(2).withTitle('Schedule'),
DTColumnDefBuilder.newColumnDef(3).withTitle('Action')
];
});
}
results.data不为空。它具有来自数据库的价值。这是数据。
[对象,对象,对象,对象,对象,对象,对象,对象]
0
:
Object
__v
:
0
_id
:
"578cf46fc80f7ae809a5a095"
lastpull
:
"2016-07-19T06:16:26.000Z"
name
:
"Nike SB"
schedule
:
"01:30"
__proto__
:
Object
1
:
Object
__v
:
0
_id
:
"578d7c1b1ec87f1826b1ca1a"
lastpull
:
"2016-07-19T06:16:45.000Z"
name
:
"DC Team"
schedule
:
"02:30"
__proto__
:
Object
2
:
Object
3
:
Object
4
:
Object
5
:
Object
6
:
Object
7
:
Object
如果我错过了什么,请告诉我,我已经bangin&#39;我的头一天。