javascript AngularJS ui-Grid 文本对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33443729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AngularJS ui-Grid text alignment
提问by Adrew
I created a ui-grid in a modal within angualr js. In the modal each tab has its own ui grid. For this Profile tab I have a grid and I want to align the column titles being modified and originals. I also want to align the content within the Originals column. I am new to this, so any help is appreciated.
我在 angualr js 中的模态中创建了一个 ui-grid。在模态中,每个选项卡都有自己的 ui 网格。对于此配置文件选项卡,我有一个网格,我想将正在修改的列标题与原始列标题对齐。我还想对齐 Originals 列中的内容。我是新手,所以任何帮助表示赞赏。
Code for Profile.js:
Profile.js 的代码:
var app = angular.module('serviceDesk.restroom-services.profile', []);
app.controller('ProfileCtrl', [ '$scope', '$http', function($scope, $http) {
$scope.gridOptions = {
showGridFooter: true,
enableHorizontalScrollbar: 0,
showColumnFooter: false,
enableFiltering: false,
enableColumnMenus: false,
enableGridMenu: false,
columnDefs: [
{ field: 'empty', width: '33%', displayName: ''},
{ field: 'modified', width: '33%', displayName: 'Modified'},
{ field: 'original', width: '33%', displayName: 'Originals'},
],
data: [{
"empty":"Number of Employees(Daily)",
"modified":"",
"original":"20",
},
{
"empty":"Customer Restroom Visits(Daily)",
"modified":"",
"original":"5",
},
{
"empty":"Days Open per Week",
"modified":"",
"original":"5",
},
{
"empty":"Number of Restrooms",
"modified":"",
"original":"2",
},
{
"empty":"Number of Stalls",
"modified":"",
"original":"2",
},
{
"empty":"Number of Urinals",
"modified":"",
"original":"2",
},
{
"empty":"Delivery Frequency",
"modified":"",
"original":"Weekly Deliveries",
},
{
"empty":"Billing Frequency",
"modified":"",
"original":"Monthly",
}
],
onRegisterApi: function(gridApi) {
$scope.gridApi = gridApi;
}
};
$http.get("app/views/restroom-services/action/profile/profile.json").success(function(data) {
$scope.gridOptions.data = data;
});
}
]);
Not sure if this is needed but here is the code for Profile.html:
不确定这是否需要,但这里是 Profile.html 的代码:
<div ng-controller="ProfileCtrl">
<!--button for profile..
<div class="users-button-group">
<button type="button" class="btn btn-aramark-primary btn-xs" ng-click="">Revert Profile</button>
</div>
-->
<div class="modal-body">
<div id="grid1" ui-grid="gridOptions" class="grid"></div>
</div>
回答by Adrew
I figured out the problem.
我解决了这个问题。
Here I have two divs within the html page:
这里我在 html 页面中有两个 div:
<div id="gridTest" ui-grid="gridOptions" class="grid"></div>
<div id="grid1" ui-grid="gridOptions2" class="grid"></div>
Here I am set the text to align center so that the header text is centered:
在这里,我将文本设置为居中对齐,以便标题文本居中:
#gridTest .ui-grid-header-cell .ui-grid-cell-contents{
text-align:center;
}
After all this the header row should be aligned to the center.
毕竟,标题行应该与中心对齐。