Angular Ui-网格日期格式工具提示
Angular Ui-Grid Date Format tooltip
我想在 UI-Grid 的名称列中显示工具提示,例如:
columnDefs: [
{
field: 'MemberName', dispalyName: 'Member Name',
cellTooltip: function (row, col) {
return 'Total Hous of ' + row.entity.MemberName + ' at the end of ' + row.entity.date;
}
}
`
如何更改 row.entity.date 的格式?
您需要在控制器中添加 $filter 引用。然后只需使用 $filter 来格式化日期。
app.controller('MainCtrl', ['$scope', '$http', 'uiGridConstants', '$filter', function ($scope, $http, uiGridConstants, $filter) {
$scope.gridOptions = {
enableSorting: true,
columnDefs: [
{ field: 'MemberName', dispalyName: 'Member Name',
cellTooltip: function (row, col) {
return 'Name: ' + row.entity.name + ' Company: ' + $filter('date')(row.entity.date, 'yyyy-MM-dd');
}
}
]};
}]);
我也添加了一个 plunker 示例。
我想在 UI-Grid 的名称列中显示工具提示,例如:
columnDefs: [
{
field: 'MemberName', dispalyName: 'Member Name',
cellTooltip: function (row, col) {
return 'Total Hous of ' + row.entity.MemberName + ' at the end of ' + row.entity.date;
}
}
`
如何更改 row.entity.date 的格式?
您需要在控制器中添加 $filter 引用。然后只需使用 $filter 来格式化日期。
app.controller('MainCtrl', ['$scope', '$http', 'uiGridConstants', '$filter', function ($scope, $http, uiGridConstants, $filter) {
$scope.gridOptions = {
enableSorting: true,
columnDefs: [
{ field: 'MemberName', dispalyName: 'Member Name',
cellTooltip: function (row, col) {
return 'Name: ' + row.entity.name + ' Company: ' + $filter('date')(row.entity.date, 'yyyy-MM-dd');
}
}
]};
}]);
我也添加了一个 plunker 示例。