@@ -427,39 +427,42 @@ angular.module('ui.grid')
427
427
428
428
self . displayName = ( colDef . displayName === undefined ) ? gridUtil . readableColumnName ( colDef . name ) : colDef . displayName ;
429
429
430
- var colDefWidth = colDef . width ;
431
- var parseErrorMsg = "Cannot parse column width '" + colDefWidth + "' for column named '" + colDef . name + "'" ;
432
-
433
- if ( ! angular . isString ( colDefWidth ) && ! angular . isNumber ( colDefWidth ) ) {
434
- self . width = '*' ;
435
- } else if ( angular . isString ( colDefWidth ) ) {
436
- // See if it ends with a percent
437
- if ( gridUtil . endsWith ( colDefWidth , '%' ) ) {
438
- // If so we should be able to parse the non-percent-sign part to a number
439
- var percentStr = colDefWidth . replace ( / % / g, '' ) ;
440
- var percent = parseInt ( percentStr , 10 ) ;
441
- if ( isNaN ( percent ) ) {
430
+ if ( ! angular . isNumber ( self . width ) || ! self . hasCustomWidth || colDef . allowCustomWidthOverride ) {
431
+ var colDefWidth = colDef . width ;
432
+ var parseErrorMsg = "Cannot parse column width '" + colDefWidth + "' for column named '" + colDef . name + "'" ;
433
+ self . hasCustomWidth = false ;
434
+
435
+ if ( ! angular . isString ( colDefWidth ) && ! angular . isNumber ( colDefWidth ) ) {
436
+ self . width = '*' ;
437
+ } else if ( angular . isString ( colDefWidth ) ) {
438
+ // See if it ends with a percent
439
+ if ( gridUtil . endsWith ( colDefWidth , '%' ) ) {
440
+ // If so we should be able to parse the non-percent-sign part to a number
441
+ var percentStr = colDefWidth . replace ( / % / g, '' ) ;
442
+ var percent = parseInt ( percentStr , 10 ) ;
443
+ if ( isNaN ( percent ) ) {
444
+ throw new Error ( parseErrorMsg ) ;
445
+ }
446
+ self . width = colDefWidth ;
447
+ }
448
+ // And see if it's a number string
449
+ else if ( colDefWidth . match ( / ^ ( \d + ) $ / ) ) {
450
+ self . width = parseInt ( colDefWidth . match ( / ^ ( \d + ) $ / ) [ 1 ] , 10 ) ;
451
+ }
452
+ // Otherwise it should be a string of asterisks
453
+ else if ( colDefWidth . match ( / ^ \* + $ / ) ) {
454
+ self . width = colDefWidth ;
455
+ }
456
+ // No idea, throw an Error
457
+ else {
442
458
throw new Error ( parseErrorMsg ) ;
443
459
}
444
- self . width = colDefWidth ;
445
- }
446
- // And see if it's a number string
447
- else if ( colDefWidth . match ( / ^ ( \d + ) $ / ) ) {
448
- self . width = parseInt ( colDefWidth . match ( / ^ ( \d + ) $ / ) [ 1 ] , 10 ) ;
449
460
}
450
- // Otherwise it should be a string of asterisks
451
- else if ( colDefWidth . match ( / ^ \* + $ / ) ) {
452
- self . width = colDefWidth ;
453
- }
454
- // No idea, throw an Error
461
+ // Is a number, use it as the width
455
462
else {
456
- throw new Error ( parseErrorMsg ) ;
463
+ self . width = colDefWidth ;
457
464
}
458
465
}
459
- // Is a number, use it as the width
460
- else {
461
- self . width = colDefWidth ;
462
- }
463
466
464
467
self . minWidth = ! colDef . minWidth ? 30 : colDef . minWidth ;
465
468
self . maxWidth = ! colDef . maxWidth ? 9000 : colDef . maxWidth ;
0 commit comments