0

我应该在网格中显示一个图像我有这个代码:

$scope.gridOptions = {
            data: 'items',
            enablePaging: true,
            showFooter: true,
            enablePinning: true,
            totalServerItems:'totalServerItems',
            pagingOptions: $scope.pagingOptions,
            filterOptions: $scope.filterOptions,
            showSelectionCheckbox: true,
            multiSelect: false,
            rowTemplate: '<div ng-style="{\'cursor\': row.cursor, \'z-index\': col.zIndex(),\'height\': \'150px\' }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell {{col.cellClass}}" ng-cell></div>',
            columnDefs: [
                    {field: 'id', displayName: 'Id'}, 
                    {field:'firstname', displayName:'Name'}, 
                    {field: 'surname', displayName:'Cognome'},
                    {field: 'email', displayName:'Email'},
                    {field: 'address', displayName:'Indirizzo'},
                    {field: 'city', displayName:'Città'},
                    {field: 'zip', displayName:'Cap'},
                    {field: 'birthday', displayName:'Data di nascita'},
                    {field: 'joined', displayName:'Registrazione'},
                    {field: 'ip', displayName:'Ip'},
                    {field: 'url', displayName:'Prodotto',cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><img src="./assets/base/img/products/{{row.getProperty(\'url\')}}" /></div>'},
                ] 
            };

    });

除了图像高度(它与行高一起显示)之外,一切都很好

我试过了

rowTemplate: '<div ng-style="{\'cursor\': row.cursor, \'z-index\': col.zIndex(),\'height\': \'150px\' }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell {{col.cellClass}}" ng-cell></div>',

或者简单地将样式放在 div img 模板上

但它不起作用所以有没有办法设置行/单元格的高度?

4

1 回答 1

8

It's very simple if you know ^^

$scope.gridOptions = {
            data: 'items',
            rowHeight: 80,
            enablePaging: true,
            showFooter: true,
            enablePinning: true,
            totalServerItems:'totalServerItems',
            pagingOptions: $scope.pagingOptions,
            filterOptions: $scope.filterOptions,
            showSelectionCheckbox: true,
            multiSelect: false,
            columnDefs: [
                    {field: 'id', displayName: 'Id'}, 
                    {field:'firstname', displayName:'Name'}, 
                    {field: 'surname', displayName:'Cognome'},
                    {field: 'email', displayName:'Email'},
                    {field: 'address', displayName:'Indirizzo'},
                    {field: 'city', displayName:'Città'},
                    {field: 'zip', displayName:'Cap'},
                    {field: 'birthday', displayName:'Data di nascita'},
                    {field: 'joined', displayName:'Registrazione'},
                    {field: 'ip', displayName:'Ip'},
                    {field: 'url', displayName:'Prodotto',cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><img src="./assets/base/img/products/{{row.getProperty(\'url\')}}" /></div>'},
                ] 
            };

    });

simply add rowHeight: 80, to your grid options

于 2013-10-02T07:57:30.293 回答