1
- import { IFilterService , IQService } from 'angular' ;
1
+ import { IQService } from 'angular' ;
2
2
import { IColumnDef , IGridColumn , IGridInstance , IGridOptions , IGridRow } from 'ui-grid' ;
3
3
import { Measurer } from './Measurer' ;
4
4
import { UiGridMetrics } from './UiGridMetrics' ;
@@ -27,7 +27,7 @@ export class UiGridAutoFitColumnsService {
27
27
static $inject = [ '$q' , '$filter' , '$parse' ] ;
28
28
private gridMetrics : UiGridMetrics ;
29
29
30
- constructor ( private $q : IQService , private $filter : IFilterService ) {
30
+ constructor ( private $q : IQService ) {
31
31
this . gridMetrics = new UiGridMetrics ( ) ;
32
32
}
33
33
@@ -43,31 +43,6 @@ export class UiGridAutoFitColumnsService {
43
43
gridOptions . enableColumnAutoFit = gridOptions . enableColumnAutoFit !== false ;
44
44
}
45
45
46
- private getFilterIfExists < T > ( filterName ) : any {
47
- try {
48
- return this . $filter < IAnyFilterPredicateFunc > ( filterName ) ;
49
- } catch ( e ) {
50
- return null ;
51
- }
52
- }
53
-
54
- private getFilteredValue ( value : string , cellFilter : string ) {
55
- if ( cellFilter && cellFilter !== '' ) {
56
- const filter = this . getFilterIfExists ( cellFilter ) ;
57
- if ( filter ) {
58
- value = filter ( value ) ;
59
- } else {
60
- // https://regex101.com/r/rC5eR5/2
61
- const re = / ( [ ^ : ] * ) : ( [ ^ : ] * ) : ? ( [ \s \S ] + ) ? / ;
62
- let matches ;
63
- if ( ( matches = re . exec ( cellFilter ) ) !== null ) {
64
- value = this . $filter < IAnyFilterPredicateFunc > ( matches [ 1 ] ) ( value , matches [ 2 ] , matches [ 3 ] ) ;
65
- }
66
- }
67
- }
68
- return value ;
69
- }
70
-
71
46
colAutoFitColumnBuilder ( colDef : IExtendedColumnDef , col : IExtendedGridColumn , gridOptions : IExtendedGridOptions ) {
72
47
const promises = [ ] ;
73
48
@@ -106,12 +81,7 @@ export class UiGridAutoFitColumnsService {
106
81
optimalWidths [ columnKey ] = Measurer . measureRoundedTextWidth ( column . displayName , this . gridMetrics . getHeaderFont ( ) ) + this . gridMetrics . getHeaderButtonsWidth ( ) ;
107
82
108
83
rows . forEach ( ( row ) => {
109
- let cellText = row . grid . getCellValue ( row , column ) ;
110
-
111
- if ( ! ! column . colDef . cellFilter ) {
112
- cellText = this . getFilteredValue ( cellText , column . colDef . cellFilter ) ;
113
- }
114
-
84
+ const cellText = row . grid . getCellDisplayValue ( row , column ) ;
115
85
const currentCellWidth = Measurer . measureRoundedTextWidth ( cellText , this . gridMetrics . getCellFont ( ) ) ;
116
86
const optimalCellWidth = currentCellWidth > 300 ? 300 : currentCellWidth ;
117
87
0 commit comments