我使用AngularJs来创建我的前端项目。 我的目标是以这种方式在uib-accordion,uib-accordion-group元素中创建dinamically N数据表:
<uib-accordion class="" close-others="true">
<div uib-accordion-group class="panel-default" ng-repeat="service in orderOrganizerCtrl.tableServiceIdFilter">
<uib-accordion-heading>
{{'2101_OrderEntry.Organizer.Service' | translate}}{{service.key}} <br/>
<span>{{'2101_OrderEntry.Organizer.SelectedAgenda' | translate}}</span> {{ orderOrganizerCtrl.getAgendaName(service.key) }} <br/>
<span>{{'2101_OrderEntry.Organizer.DateHourSelected' | translate}}</span> {{ orderOrganizerCtrl.getAppointment(service.key) }}
</uib-accordion-heading>
<!-- Here, datatable content -->
<table class="table data-table row-border hover" id="agenda_{{service.key}}" datatable="ng">
<thead>
<th class="sorting_asc">{{'2101_OrderEntry.Organizer.AgendaServices' | translate}}</th>
<th class="sorting_asc sorting_1">{{'2101_OrderEntry.Organizer.DateAppointment' | translate}}</th>
<th class="sorting_asc">{{'2101_OrderEntry.Organizer.HourAppointment' | translate}}</th>
</thead>
<tbody>
<tr ng-click="orderOrganizerCtrl.selectRow(item, 'agenda_' + service.key, service.key)" ng-repeat="item in orderOrganizerCtrl.agendaSimplified track by $index" ng-if="item.serviceName === service.key">
<td align="center">{{item.agendaName}}</td>
<td align="center">{{item.dateAppointment| date:'dd MM yyyy'}}</td>
<td align="center">{{item.hourAppointment}}</td>
</tr>
</tbody>
</table>
</div>
</uib-accordion>
&#13;
我的问题是排序&#34; dateAppointment&#34;柱。每个&#34; item.dateAppointment&#34; element是一个Date元素。为什么排序不起作用?我试图以这种方式使用DTColumnDefBuilder和dtColumnDefs的定义:
this.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(1).
.withOption('type', 'date')
];
&#13;
但是它不起作用(可能是因为表是以dinamically方式创建的)。 有人可以帮帮我吗?
答案 0 :(得分:1)
您应指定排序顺序和要排序的列。试试这个:
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withPaginationType('full_numbers')
.withDisplayLength(10)
.withOption('order', [0, 'desc']);
$scope.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).withOption('type', 'date'),
DTColumnDefBuilder.newColumnDef(1).notSortable(),
DTColumnDefBuilder.newColumnDef(2).notSortable(),
DTColumnDefBuilder.newColumnDef(3).notSortable(),
...
];
此处,第一列将是日期列。希望它有所帮助..