projects/i-components/src/lib/components/grid-column-definition/grid-column-definition.component.ts
Angular Component for the ColumnDefinition.
selector | wm-grid-column-definition |
styleUrls | ./grid-column-definition.component.scss |
templateUrl | ./grid-column-definition.component.html |
Properties |
|
Methods |
Inputs |
Accessors |
constructor(injector: Injector, injectedModel: GridColumnDefinition)
|
|||||||||
Creates an instance of GridColumnDefinitionComponent.
Parameters :
|
maxWidth | |
Type : number
|
|
Sets the maxWidth for the column |
minWidth | |
Type : number
|
|
Sets the minWidth for the column |
model | |
Type : GridColumnDefinition
|
|
Object with properties and events for the GridColumnDefinition. |
width | |
Type : string
|
|
Property used to save the column width. |
ngOnInit |
ngOnInit()
|
Angular lifecycle.
Returns :
void
|
model |
Type : GridColumnDefinition
|
Decorators :
@Input()
|
Object with properties and events for the GridColumnDefinition. |
Private modelProxy |
Type : GridColumnDefinition
|
Default value : ModelProxy.create<GridColumnDefinition>()
|
ModelProxy is a copy of the model, used on the component initial building to prevent crashes with external bindings. |
width | ||||||
setwidth(value: string)
|
||||||
Property used to save the column width.
Parameters :
Returns :
void
|
maxWidth | ||||||
getmaxWidth()
|
||||||
Gets the maxWidth for the column
Returns :
number
|
||||||
setmaxWidth(value: number)
|
||||||
Sets the maxWidth for the column
Parameters :
Returns :
void
|
minWidth | ||||||
getminWidth()
|
||||||
Gets the maxWidth for the column
Returns :
number
|
||||||
setminWidth(value: number)
|
||||||
Sets the minWidth for the column
Parameters :
Returns :
void
|
widthValue |
getwidthValue()
|
Gets the Width value from the GridColumnDefinition model.
Returns :
number
|
import { Component, Injector, Input, OnInit, Optional } from '@angular/core';
import {
GridColumnDefinition,
GridLength,
ModelProxy,
GridUnitType,
} from '@mobilize/wms-framework';
/**
* Angular Component for the ColumnDefinition.
*
* @export
* @class GridColumnDefinitionComponent
* @implements {OnInit}
*/
@Component({
selector: 'wm-grid-column-definition',
templateUrl: './grid-column-definition.component.html',
styleUrls: ['./grid-column-definition.component.scss'],
})
export class GridColumnDefinitionComponent implements OnInit {
/**
* Object with properties and events for the GridColumnDefinition.
*
* @type {GridColumnDefinition}
* @memberof GridColumnDefinitionComponent
*/
@Input()
model: GridColumnDefinition;
/**
* ModelProxy is a copy of the model, used on the component initial building to prevent crashes with external bindings.
*
* @private
* @type {GridColumnDefinition}
* @memberof GridColumnDefinitionComponent
*/
private modelProxy: GridColumnDefinition =
ModelProxy.create<GridColumnDefinition>();
/**
* Creates an instance of GridColumnDefinitionComponent.
*
* @param {Injector} injector
* @param {GridColumnDefinition} [injectedModel=null]
* @memberof GridColumnDefinitionComponent
*/
/* istanbul ignore next */
constructor(
private injector: Injector,
@Optional() protected injectedModel: GridColumnDefinition = null
) {
this.model = injectedModel;
}
/**
* Property used to save the column width.
*
* @memberof GridColumnDefinitionComponent
*/
@Input()
set width(value: string) {
if (Number(value)) {
this.modelProxy.Width = new GridLength(Number(value), GridUnitType.Pixel);
} else if (value.toLowerCase() === 'auto') {
this.modelProxy.Width = new GridLength(0, GridUnitType.Auto);
} /* istanbul ignore else */ else if (value.endsWith('*')) {
const starNumber =
Number(value.slice(0, -1)) === 0 ? 1 : Number(value.slice(0, -1));
this.modelProxy.Width = new GridLength(starNumber, GridUnitType.Star);
}
}
/**
* Sets the maxWidth for the column
*
* @memberof GridColumnDefinitionComponent
*/
@Input()
set maxWidth(value: number) {
this.modelProxy.MaxWidth = value;
}
/**
* Gets the maxWidth for the column
*
* @readonly
* @type {number}
* @memberof GridColumnDefinitionComponent
*/
get maxWidth(): number {
return this.model.MaxWidth;
}
/**
* Sets the minWidth for the column
*
* @memberof GridColumnDefinitionComponent
*/
@Input()
set minWidth(value: number) {
this.modelProxy.MinWidth = value;
}
/**
* Gets the maxWidth for the column
*
* @readonly
* @type {number}
* @memberof GridColumnDefinitionComponent
*/
get minWidth(): number {
return this.model.MinWidth;
}
/**
* Gets the Width value from the GridColumnDefinition model.
*
* @readonly
* @type {number}
* @memberof GridColumnDefinitionComponent
*/
get widthValue(): number {
return this.model.Width.Value;
}
/**
* Angular lifecycle.
*
* @memberof GridColumnDefinitionComponent
*/
ngOnInit(): void {
this.model = this.model || this.injectedModel || new GridColumnDefinition();
ModelProxy.copy(this.modelProxy, this.model);
this.modelProxy = this.model;
}
}
<div></div>
./grid-column-definition.component.scss