我正在为我的项目使用 angular js 数据表。这是我用于我的应用程序的插件。 angular js data table
根据要求,我只加载了表的第一个记录集(数组 0 索引)。 我正在使用以下函数加载数据
$scope.loadApprovedData = function () {
$scope.dtOptionsApproved = DTOptionsBuilder.newOptions()
.withOption('ajax', {
dataType: 'json',
contentType: "application/json; charset=utf-8",
url: appConfig.apiUrl + "/finalizedList?status=APPROVED",
xhrFields: { withCredentials: true },
type: 'POST',
data: function (d) {
return JSON.stringify(d);
},
error: function (response) {
ajaxErrorHandler.handle(response);
}
})
.withDataProp('data')
.withOption('processing', true)
.withOption('serverSide', true)
.withOption('scrollY', '400px')
.withOption('scrollX', '100%')
.withOption('scrollCollapse', true)
.withOption('searching', true)
.withLightColumnFilter({
'0': { type: 'text' },
'1': { type: 'text' }
})
.withOption('drawCallback', function (settings) {
});
$scope.dtOptionsApproved.withOption('fnRowCallback',
function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$compile(nRow, aData, iDisplayIndex, iDisplayIndexFull)($scope);
});
$scope.dtColumnsApproved = [
DTColumnBuilder.newColumn('traceId').withTitle('Trace ID'),
DTColumnBuilder.newColumn('approval.0.name').withTitle('Name').notSortable(),
DTColumnBuilder.newColumn('approval.0.matchRatio').withTitle('Match Strength %').notSortable(),
DTColumnBuilder.newColumn('approval.0.resultId').withTitle('Action').renderWith(function (data, type, full) {
return '<div class="btn-group-xs">' +
' <button type="button" class="btn btn-flat btn-xs btn-success" ng-click="openDetailViewWindow(\'' + data + '\');">' +
' <i class="ion ion-eye"></i>' +
' </button>' +
'</div>';
}).withClass('text-center').notSortable()
];
}
我的数据如下
{
"data":[
{
"traceId":"KYC4544443610",
"status":"APPROVED",
"approval":[
{
"resultId":"45jb6ug8qs9y11fmvdgutxb5td",
"name":"piyumi desilva",
"matchRatio":100
},
{
"resultId":"45xjdb6ug8qsx9y11fmvdgutxb5td",
"name":"piyumi desillva",
"matchRatio":90
}
]
},
{
"traceId":"KYC4544443613",
"status":"APPROVED",
"approval":[
{
"resultId":"45apd16us8qsx9y11fmvdgutxb5td",
"name":"amilaa perera",
"matchRatio":100
},
{
"resultId":"45apd26us8qsx9y11fmvdgutxb5td",
"name":"amissl perera",
"matchRatio":90
}
]
}
]
}
第一列过滤器代表“traceId”。它运作良好。第二列过滤器代表“名称”。它在数组内。
加载 traceId-> DTColumnBuilder.newColumn('traceId').withTitle('Trace ID')
加载名称(数组中的第一条记录)-> DTColumnBuilder.newColumn('approval.0.name').withTitle('Name').notSortable(),
为什么只有名称列过滤器不起作用?你能帮我解决这个问题吗?