我在网格中插入了一些虚拟对象,网格中的数据显示发现了一些问题。这是我的代码:
html:
<div class="gridStyle" ui-grid="gridOptions"></div>联署材料:
$scope.myData = [{
JobId: '196',
siteType: 'abc',
Title: 'Happy womans day',
Message: 'hello',
devicetype: 'A',
jobDuration: '819',
totalMsgs: '2016',
msgsDelivered: 'Msg not found In the whole Body',
msgsFailed: '789',
jobCreatedDate: '11-03-2015',
jobCreatedBy: 'abc@abc.com'
}];
$scope.gridOptions = {
data: 'myData'
};css:
.ui-grid-header-cell .ui-grid-cell-contents {
height: 48px;
white-space: normal;
-ms-text-overflow: clip;
-o-text-overflow: clip;
text-overflow: clip;
overflow: visible;
}数据显示在网格中,但只能显示到一定的宽度。无法包装长文,如: Msg未在全身找到,显示为Msg非名词.
发布于 2015-03-28 04:20:36
好吧,有几件事。
首先,要设置需要使用列定义的列宽度,则可以在每个列上设置以像素或百分比为单位的宽度。请参考editable作为一个具有列宽度的示例。
其次,还有添加工具提示的功能,这是显示不适合可用空间的较长单元格的一种方法。参考tooltips
第三,您可以使行更高,从而在其中有包装内容的空间。请注意,所有行都必须是相同的高度,所以您不能只使需要它的行更高。
gridOptions.rowHeight = 50;您还需要在div上设置空格属性,以便将其包装起来,这可以通过在cellTemplate中设置类,然后向css添加样式来完成。
以柱塞为例:http://plnkr.co/edit/kyhRm08ZtIKYspDqgyRa?p=preview
发布于 2015-08-25 07:03:29
设置javascript的依赖项:
angular.module('app', [
'ngTouch',
'ui.grid',
'ui.grid.autoResize',
'ui.grid.resizeColumns'
])对于ui-grid 3.0,我使用以下指令:
.directive('setOuterHeight',['$timeout', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element) {
$timeout(function(){
// Get the Parent Divider.
var parentContainer = element.parent()[0];
console.log(parentContainer.offsetHeight);
// Padding of ui-grid-cell-contents is 5px.
// TODO: Better way to get padding height?
var topBottomPadding = 10;
//Get the wrapped contents rowHeight.
var rowHeight = topBottomPadding + parentContainer.offsetHeight;
var gridRowHeight = scope.grid.options.rowHeight;
// Get current rowHeight
if (!gridRowHeight ||
(gridRowHeight && gridRowHeight < rowHeight)) {
// This will OVERRIDE the existing rowHeight.
scope.grid.options.rowHeight = rowHeight;
}
},0);
}
};
}])在主计长之下:
.controller('MainCtrl',
['$scope', '$q', '$timeout', 'uiGridConstants',
function ($scope, $q, $timeout, uiGridConstants) {
$scope.gridOptions = {
enableVerticalScrollbar: uiGridConstants.scrollbars.NEVER,
enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER,
columnDefs: [
{name: 'firstName', width: '*'},
{name: 'lastName', width: '*'},
{
name: 'company', width: '*',
cellTooltip: function (row) {
return row.entity.company;
},
cellTemplate: '<div class="ui-grid-cell-contents wrap" title="TOOLTIP"><div><span class="label" set-row-height>{{row.entity.company}} </span></div><div>'
},
{name: 'employed', width: '*'}
],
enableColumnResize: true,
rowHeight: 10,
};
}]);*注意cellTemplate的设置行高度指令。
对于CSS,您必须将空白设置为正常的:
.wrap {
white-space: normal;
}
.wrap .label {
display: inline-block;
}最后,更改网格高度的HTML:
<div id="grid1" ui-grid="gridOptions" class="grid" ng-style="{height: (gridOptions.data.length*gridOptions.rowHeight)+32+'px'}" ui-grid-resize-columns ui-grid-auto-resize></div>柱塞示例如下:http://plnkr.co/edit/OwgEfru0QyFaU1XJFezv?p=preview
https://stackoverflow.com/questions/29298968
复制相似问题