gpt4 book ai didi

angularjs - Angular 数据表 - 呈现以组合来自多列的数据

转载 作者:行者123 更新时间:2023-12-01 11:30:03 25 4
gpt4 key购买 nike

我的数据表 angularjs Controller 代码如下。使用 DTColumnBuilder 选项,我如何提供列渲染器来显示格式化数据

$scope.dtOptions = DTOptionsBuilder.fromSource(CompanyService.loadUrl()).withPaginationType('full_numbers').withOption('rowCallback', rowCallback);
$scope.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('Id'),
DTColumnBuilder.newColumn('name').withTitle('Name'),
DTColumnBuilder.newColumn('description').withTitle('Description'),
DTColumnBuilder.newColumn('active_status').withTitle('Status')
];

最佳答案

帮助我编写渲染器的链接https://github.com/l-lin/angular-datatables/issues/224

    $scope.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('Id'),
DTColumnBuilder.newColumn('name').withTitle('Name'),

DTColumnBuilder.newColumn(null).withTitle('Address').renderWith(function(data,type,full) {
var address = '<address>' + data.address_line_1+ '<br>';
if (data.address_line_2.trim()) {
address = address + data.address_line_2+ '<br>';
}
address = address + data.location + '<br>'
+ data.city + '-' + data.pincode + '<br>'
+ data.state +'<br>'
+ data.country;
return address;

}),

DTColumnBuilder.newColumn('city').withTitle('City'),
DTColumnBuilder.newColumn('state').withTitle('State'),
DTColumnBuilder.newColumn('country').withTitle('Country'),
];

关于angularjs - Angular 数据表 - 呈现以组合来自多列的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32892135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com