File

projects/wms-framework/src/lib/models/controls/XamGridColumnModel.ts

Description

Base model class representing the column model.

Extends

XamGridColumnBaseModel

Index

Properties
Methods
Accessors

Constructor

constructor()

Creates an instance of XamGridColumnModel.

Properties

_isReadOnly
Default value : false
Protected _isSortable
Type : boolean
Default value : true

Check if the column is sortable True by default

Private _isSorted
Type : SortDirection
Default value : SortDirection.None

Flag to determine the sorting direction being used

Public ActualWidth
Type : number
Default value : 0
Static AddNewRowCellStyleProperty
Type : DependencyProperty
Default value : new DependencyProperty('AddNewRowCellStyle', null, null)

AddNewRowCellStyleProperty dependency property

Static AddNewRowEditorTemplateHorizontalContentAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'AddNewRowEditorTemplateHorizontalContentAlignment', null, null )

AddNewRowEditorTemplateHorizontalContentAlignmentProperty dependency property

Static AddNewRowEditorTemplateProperty
Type : DependencyProperty
Default value : new DependencyProperty('AddNewRowEditorTemplate', null, null)

AddNewRowEditorTemplateProperty dependency property

Static AddNewRowEditorTemplateVerticalContentAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'AddNewRowEditorTemplateVerticalContentAlignment', null, null )

AddNewRowEditorTemplateVerticalContentAlignmentProperty dependency property

Static AddNewRowItemTemplateHorizontalContentAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'AddNewRowItemTemplateHorizontalContentAlignment', null, null )

AddNewRowItemTemplateHorizontalContentAlignmentProperty dependency property

Static AddNewRowItemTemplateProperty
Type : DependencyProperty
Default value : new DependencyProperty('AddNewRowItemTemplate', null, null)

AddNewRowItemTemplateProperty dependency property

Static AddNewRowItemTemplateVerticalContentAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'AddNewRowItemTemplateVerticalContentAlignment', null, null )

AddNewRowItemTemplateVerticalContentAlignmentProperty dependency property

Public AllowToolTips
Type : AllowToolTips
Decorators :
@Dependency(XamGridColumnModel.AllowToolTipsProperty)

Gets or sets allow tooltips

Static AllowToolTipsProperty
Type : DependencyProperty
Default value : new DependencyProperty('AllowToolTips', AllowToolTips.Never, null)

AllowToolTipsProperty dependency property

Public AutoSizeHeader
Default value : true

Mobilize custom property. Gets or sets if the column header should adjust the width property.

Private cachedTemplateInHeaderStyle
Type : literal type
Default value : null

Stores the information about the Template in HeaderStyle.

Public CalculatedWidth
Type : string
Default value : '0'

CalculatedWidth property.

Public CellStyle
Type : RuntimeStyleInfo
Default value : null
Public ConditionalFormatCollection
Default value : new ConditionalFormatCollection()
Public Editable
Default value : false

Check if the column is Editable.

Public FilterColumnSettings
Default value : new FilterColumnSettings()
Public FilterTemplate
Type : DataTemplate

FilterTempalte property.

Static FirstSortDirectionProperty
Type : DependencyProperty
Default value : new DependencyProperty('FirstSortDirection', null, null)

FirstSortDirectionProperty dependency property

footerOperand
Type : any

Footer operand used to display the footer text.

Public FooterStyle
Type : RuntimeStyleInfo
Default value : null
Inherited from XamGridColumnBaseModel
Public FooterText
Type : string
Decorators :
@Dependency(XamGridColumnModel.FooterTextProperty)

Gets or sets the footer text

Static FooterTextProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'FooterText', '', XamGridColumnModel.FooterTextChangedCallback, new RuntimeTypeInfoImpl(String) )

FooterTextProperty dependency property

Static GroupByHeaderCellStyleProperty
Type : DependencyProperty
Default value : new DependencyProperty('GroupByHeaderCellStyle', null, null)

GroupByHeaderCellStyleProperty dependency property

Static GroupByItemTemplateProperty
Type : DependencyProperty
Default value : new DependencyProperty('GroupByItemTemplate', null, null)

GroupByItemTemplateProperty dependency property

Static GroupByRowCellStyleProperty
Type : DependencyProperty
Default value : new DependencyProperty('GroupByRowCellStyle', null, null)

GroupByRowCellStyleProperty dependency property

Public HeaderStyle
Type : RuntimeStyleInfo
Decorators :
@Dependency(XamGridColumnModel.HeaderStyleProperty)

Gets or sets the style to be used by the column header.

Static HeaderStyleProperty
Type : DependencyProperty
Default value : new DependencyProperty('HeaderStyle', null, null)

HeaderStyle dependency property.

Public HeaderTemplate
Type : DataTemplate
Public HeaderTextHorizontalAlignment
Type : HorizontalAlignment
Decorators :
@Dependency(XamGridColumnModel.HeaderTextHorizontalAlignmentProperty)

Gets or sets the header text horizontal alignment

Static HeaderTextHorizontalAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty('HeaderTextHorizontalAlignment', null, null)

HeaderTextHorizontalAlignmentProperty dependency property

Static HeaderTextVerticalAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty('HeaderTextVerticalAlignment', null, null)

HeaderTextVerticalAlignmentProperty dependency property

Public HorizontalContentAlignment
Type : HorizontalAlignment
Default value : HorizontalAlignment.Left

Default GridColumn value for HorizontalContentAlignment is Left

Public IsFilterable
Type : boolean
Decorators :
@Dependency(XamGridColumnModel.IsFilterableProperty)

Check if the column is filterable.

Static IsFilterableProperty
Default value : new DependencyProperty( 'IsFilterable', true, null )

IsFilterableProperty dependency property

Public IsFixable
Default value : true
Public IsFixed
Default value : FixedState.NotFixed
Public IsGroupable
Default value : false
Public IsHideable
Default value : false
Public IsMovable
Default value : true
Public IsReadOnly
Type : boolean
Decorators :
@Dependency(XamGridColumnModel.IsReadOnlyProperty)

Check is the column is read only.

Static IsReadOnlyProperty
Default value : new DependencyProperty( 'IsReadOnly', false, XamGridColumnModel.IsReadOnlyCallBack )

IsReadOnlyProperty dependency property

Public IsResizable
Default value : true
Public MaximumWidth
Type : any
Decorators :
@Dependency(XamGridColumnModel.MaximumWidthProperty)

Gets or sets the maximun width

Static MaximumWidthProperty
Type : DependencyProperty
Default value : new DependencyProperty('MaximumWidth', null, null)

MaximumWidthProperty dependency property

Static MergeCellStyleProperty
Type : DependencyProperty
Default value : new DependencyProperty('MergeCellStyle', null, null)

MergeCellStyleProperty dependency property

Static MergedItemTemplateProperty
Type : DependencyProperty
Default value : new DependencyProperty('MergedItemTemplate', null, null)

MergedItemTemplateProperty dependency property

Public MinimumWidth
Type : any
Decorators :
@Dependency(XamGridColumnModel.MinimumWidthProperty)

Gets or sets the minimun width

Static MinimumWidthProperty
Type : DependencyProperty
Default value : new DependencyProperty('MinimumWidth', null, null)

MinimumWidthProperty dependency property

Public Parent
Type : XamGridColumnModel | XamGridModel | null
Default value : null
Decorators :
@onchange()

The parent of this column if any. Usually this is the containing column group.

Public SortComparer
Type : unknown
Default value : null
Static ToolTipContentTemplateProperty
Type : DependencyProperty
Default value : new DependencyProperty('ToolTipContentTemplate', null, null)

ToolTipContentTemplateProperty dependency property

Static ToolTipStyleProperty
Type : DependencyProperty
Default value : new DependencyProperty('ToolTipStyle', null, null)

ToolTipStyleProperty dependency property

Public ValueConverter
Type : IValueConverter
Decorators :
@Dependency(XamGridColumnModel.ValueConverterProperty)

Gets or sets the value converter

Public ValueConverterParameter
Type : unknown
Decorators :
@Dependency(XamGridColumnModel.ValueConverterParameterProperty)

Gets or set the value converter parameter

Static ValueConverterParameterProperty
Type : DependencyProperty
Default value : new DependencyProperty('ValueConverterParameter', null, null)

ValueConverterParameterProperty dependency property

Static ValueConverterProperty
Type : DependencyProperty
Default value : new DependencyProperty('ValueConverter', null, null)

ValueConverterProperty dependency property

Public VerticalContentAlignment
Type : VerticalAlignment
Default value : VerticalAlignment.Center

Default Silverlight value for VerticalContentAlignment is Center

Public Width
Type : ColumnWidth
Decorators :
@Dependency(XamGridColumnModel.WidthProperty)

Gets or sets the width

Static WidthProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Width', null, null )

WidthProperty dependency property

Private _layout
Type : ColumnLayout
Inherited from XamGridColumnBaseModel

private field for the column layout

Public DataType
Type : "string" | "number" | "date" | "boolean"
Default value : 'string'
Inherited from XamGridColumnBaseModel

DataType property.

Public HeaderText
Type : string
Decorators :
@Dependency(XamGridColumnBaseModel.HeaderTextProperty)
Inherited from XamGridColumnBaseModel

Gets or sets the HeaderText

Static HeaderTextProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'HeaderText', '', null )
Inherited from XamGridColumnBaseModel

HeaderTextProperty dependency property

Public Key
Type : string
Decorators :
@Dependency(XamGridColumnBaseModel.KeyProperty)
Inherited from XamGridColumnBaseModel

Gets or sets the key

Static KeyProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Key', '', null )
Inherited from XamGridColumnBaseModel

KeyProperty dependency property

PropertyChanged
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Inherited from XamGridColumnBaseModel
Public Tag
Type : unknown
Decorators :
@Dependency(XamGridColumnBaseModel.TagProperty)
Inherited from XamGridColumnBaseModel

Gets or sets the tag

Static TagProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Tag', null, null )
Inherited from XamGridColumnBaseModel

TagProperty dependency property

Public Visibility
Type : boolean
Decorators :
@Dependency(XamGridColumnBaseModel.VisibilityProperty)
Inherited from XamGridColumnBaseModel

Gets or sets the visibility

Static VisibilityProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Visibility', true, null )
Inherited from XamGridColumnBaseModel

VisibilityProperty dependency property

Protected bindingExpressions
Default value : new SimpleDictionary< string, BindingExpression >()
Inherited from DependencyObject
Public BindingValidationError
Default value : new SubscriptionEvent< (sender: any, e: BindingValidationErrorEventArgs) => void >()
Inherited from DependencyObject

Event for validation errors

Public change
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Inherited from DependencyObject

Infrastructure event for notifying event changes

Public Dispatcher
Type : Dispatcher
Default value : Dispatcher.GetDispatcher()
Inherited from DependencyObject
isEnableSetPropertiesRegistry
Type : boolean
Default value : true
Inherited from DependencyObject

Flag which indicates if the dependency property set mechanism is enable

Public IsInitializingBindings
Type : boolean
Default value : false
Inherited from DependencyObject

Property to determine if bindings are being initialized

previousValidationMessage
Type : string
Default value : ''
Inherited from DependencyObject
Protected properties
Type : object
Default value : {}
Inherited from DependencyObject
Private setPropertiesRegistry
Type : Map<string | boolean>
Default value : new Map()
Inherited from DependencyObject

Registry with dependencies properties which has been set

validationerr
Default value : false
Inherited from DependencyObject
validationMessagesStack
Type : Array<>
Default value : []
Inherited from DependencyObject

Keeps a queue of validation messages registered on the current Dependency Object

Methods

CreateFooterOperand
CreateFooterOperand(footerTemplate?: any)

Dynamically create a class for summaries operands. Accepts a string as a binding to render in the "footer" part of the columns.

Parameters :
Name Type Optional
footerTemplate any Yes
Returns : void
Static FooterTextChangedCallback
FooterTextChangedCallback(sender: DependencyObject, args: DependencyPropertyChangedEventArgs)

Callback function for FooterText changes.

Parameters :
Name Type Optional
sender DependencyObject No
args DependencyPropertyChangedEventArgs No
Returns : void
GenerateCell
GenerateCell(row: RowBase)
Parameters :
Name Type Optional
row RowBase No
Returns : CellBase
GenerateDataCell
GenerateDataCell(row: RowBase)
Parameters :
Name Type Optional
row RowBase No
Returns : CellBase
Static IsReadOnlyCallBack
IsReadOnlyCallBack(sender: DependencyObject, args: DependencyPropertyChangedEventArgs)

Callback function for IsReadOnly changes.

Parameters :
Name Type Optional
sender DependencyObject No
args DependencyPropertyChangedEventArgs No
Returns : void
Protected OnPropertyChanged
OnPropertyChanged(propertyName: string)

Triggers the PropertyChanged subscription event

Parameters :
Name Type Optional
propertyName string No
Returns : void
onColumnLayoutChanged
onColumnLayoutChanged()
Inherited from XamGridColumnBaseModel

method call when the column layout is changed

Returns : void
Private addRelatedSubscriptionIfRequired
addRelatedSubscriptionIfRequired(event: SubscriptionEvent<any>, theHandler: any, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
event SubscriptionEvent<any> No
theHandler any No
bindingExpression BindingExpression No
Returns : void
Private addSubscriptionForTwoWayBindings
addSubscriptionForTwoWayBindings(dependencyProperty: DependencyProperty, binding: Binding, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
dependencyProperty DependencyProperty No
binding Binding No
bindingExpression BindingExpression No
Returns : void
addsValidationMessage
addsValidationMessage(propKey: Binding | string, message: string)
Inherited from DependencyObject

Adds a new validation message associated to a binding or a property name

Parameters :
Name Type Optional
propKey Binding | string No
message string No
Returns : void
Private beginSubscribeToMultiPropertyPathChanges
beginSubscribeToMultiPropertyPathChanges(context: any, binding: Binding, dependencyProperty: DependencyProperty, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
context any No
binding Binding No
dependencyProperty DependencyProperty No
bindingExpression BindingExpression No
Returns : void
Private checkForSubscriptoinToDataErrorInfo
checkForSubscriptoinToDataErrorInfo(currentContext: any, binding: Binding, propertyToSubscribe: string, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
currentContext any No
binding Binding No
propertyToSubscribe string No
bindingExpression BindingExpression No
Returns : void
Public clearValue
clearValue(property: DependencyProperty)
Inherited from DependencyObject

Clears the dependency property value

Parameters :
Name Type Optional
property DependencyProperty No
Returns : void
Equals
Equals(obj: any)
Inherited from DependencyObject

Compares this dependency object agains another object.

Parameters :
Name Type Optional
obj any No
Returns : boolean

{boolean}

GetChild
GetChild(idx: number)
Inherited from DependencyObject

Gets the child element at the index position

Parameters :
Name Type Optional
idx number No
Returns : DependencyObject

{DependencyObject}

GetChildrenCount
GetChildrenCount()
Inherited from DependencyObject

Method o know the amount of children the parent has

Returns : number

{number}

GetHashCode
GetHashCode()
Inherited from DependencyObject

Gets a hash code for this dependency object.

Returns : number

{number}

Public getValue
getValue(property: DependencyProperty)
Inherited from DependencyObject

Gets the value of a dependency property

Parameters :
Name Type Optional
property DependencyProperty No
Returns : any
Private handleErrorsOnContext
handleErrorsOnContext(errorCtxt: INotifyDataErrorInfo, args: DataErrorsChangedEventArgs)
Inherited from DependencyObject

Check and register possible errors in an error context

Parameters :
Name Type Optional
errorCtxt INotifyDataErrorInfo No
args DataErrorsChangedEventArgs No
Returns : void
Public IsPropertySet
IsPropertySet(propertyName: string)
Inherited from DependencyObject

Indicates if the property has been already set.

Parameters :
Name Type Optional
propertyName string No
Returns : any
Private performDataErrorValidationIfRequired
performDataErrorValidationIfRequired(binding: Binding, theBindingContext: any)
Inherited from DependencyObject

Performs validation on model if the model implementes IDataErrorINfo

Parameters :
Name Type Optional
binding Binding No
theBindingContext any No
Returns : void
Private performRemoveValidationIfInValidationError
performRemoveValidationIfInValidationError(binding: Binding)
Inherited from DependencyObject

Performs the remove validation if the InValidationError is true

Parameters :
Name Type Optional
binding Binding No
Returns : void
Public performTargetObjectBindingUpdate
performTargetObjectBindingUpdate(dependencyProperty: DependencyProperty, binding: Binding)
Inherited from DependencyObject

Updates the target object value associated to the binding.

Parameters :
Name Type Optional
dependencyProperty DependencyProperty No
binding Binding No
Returns : void
Private preprocessValue
preprocessValue(property: DependencyProperty, value: any)
Inherited from DependencyObject

Preprocess value to be set to dependency property

Parameters :
Name Type Optional
property DependencyProperty No
value any No
Returns : any
Private recreateSubscriptionsForMultiPropertyBindingPath
recreateSubscriptionsForMultiPropertyBindingPath(currentContext: any, outerContext: any, properties: string[], propertyIndex: number, dependencyProperty: DependencyProperty, bindingExpression: BindingExpression, subscriptionsForCurrentBindingPath: Array<>)
Inherited from DependencyObject
Parameters :
Name Type Optional
currentContext any No
outerContext any No
properties string[] No
propertyIndex number No
dependencyProperty DependencyProperty No
bindingExpression BindingExpression No
subscriptionsForCurrentBindingPath Array<> No
Returns : void
Private registerSetPropertyIfRequired
registerSetPropertyIfRequired(name: string)
Inherited from DependencyObject

Register set property if required

Parameters :
Name Type Optional
name string No
Returns : void
Private removeSubscriptionsForMultiPropertyBindingPath
removeSubscriptionsForMultiPropertyBindingPath(subscriptionsForCurrentBindingPath: [], propertyIndex: number)
Inherited from DependencyObject
Parameters :
Name Type Optional
subscriptionsForCurrentBindingPath [] No
propertyIndex number No
Returns : void
removeValidationMessage
removeValidationMessage(propKey: Binding | string)
Inherited from DependencyObject

Removes a validation message associated to a binding or a property name

Parameters :
Name Type Optional
propKey Binding | string No
Returns : void
SetBinding
SetBinding(dependencyProperty: DependencyProperty, binding: Binding)
Inherited from DependencyObject

Sets a binding to the specified property at runtime

Parameters :
Name Type Optional Description
dependencyProperty DependencyProperty No

property to bind

binding Binding No

binding object

Returns : void
Public setValue
setValue(property: DependencyProperty, value: any)
Inherited from DependencyObject

Sets the value for a dependency property

Parameters :
Name Type Optional
property DependencyProperty No
value any No
Returns : void
Public setValueForScopedRegion
setValueForScopedRegion(property: DependencyProperty, value: any, scopedRegionManager: IRegionManager)
Inherited from DependencyObject

Sets the value for a dependency property. This is a workaround to support Scoped Region Managers. A research is required to find out the way to get the application region Manager when scoped region managers are used (when creating the DelayedRegionBehavior, the correct scoped region manager must be passed as an argument).

Parameters :
Name Type Optional
property DependencyProperty No
value any No
scopedRegionManager IRegionManager No
Returns : void
Protected shouldPreventDefaultSourceUpdate
shouldPreventDefaultSourceUpdate(dependencyProperty: DependencyProperty, binding: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
dependencyProperty DependencyProperty No
binding BindingExpression No
Returns : boolean
Private subscribeToBindingPathChanges
subscribeToBindingPathChanges(context: any, binding: Binding, dependencyProperty: DependencyProperty, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
context any No
binding Binding No
dependencyProperty DependencyProperty No
bindingExpression BindingExpression No
Returns : void
Private subscribeToErrorsChangedInModel
subscribeToErrorsChangedInModel(errorCtxt: INotifyDataErrorInfo, propertyToSubscribe: string, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
errorCtxt INotifyDataErrorInfo No
propertyToSubscribe string No
bindingExpression BindingExpression No
Returns : void
Private subscribeToPropertyChanges
subscribeToPropertyChanges(currentContext: any, outerContext: any, properties: string[], propertyIndex: number, dependencyProperty: DependencyProperty, bindingExpression: BindingExpression, subscriptionsForCurrentBindingPath: Array<>)
Inherited from DependencyObject
Parameters :
Name Type Optional
currentContext any No
outerContext any No
properties string[] No
propertyIndex number No
dependencyProperty DependencyProperty No
bindingExpression BindingExpression No
subscriptionsForCurrentBindingPath Array<> No
Returns : void
Private updateSourceOfBinding
updateSourceOfBinding(binding: Binding, outerContext: any, dependencyProperty: DependencyProperty)
Inherited from DependencyObject

Updates the source of a binding

Parameters :
Name Type Optional
binding Binding No
outerContext any No
dependencyProperty DependencyProperty No
Returns : void

Accessors

IsGroupColumn
getIsGroupColumn()

Returns whether this model represents a a column group.

TemplateInHeaderStyle
getTemplateInHeaderStyle()

If there is a Template property in HeaderStyle, returns information about such Template. Otherwise, returns null.

Returns : any
WidthResolved
getWidthResolved()

Gets the resolved grid column width

IsSorted
getIsSorted()

Returns the current sort state of this column.

Returns : SortDirection
setIsSorted(value: SortDirection)

Sets a new sort state for this column.

Parameters :
Name Type Optional
value SortDirection No
Returns : void
IsSortable
getIsSortable()

Returns the current is sortable state of this column.

Returns : boolean
setIsSortable(value: boolean)

Sets is sortable state for this column.

Parameters :
Name Type Optional
value boolean No
Returns : void
import { FrameworkElement } from '../../basecomponentmodel';
import { ControlTemplate } from '../../basecomponentmodel/Control';
import { Dependency } from '../../basecomponentmodel/Dependency';
import { DependencyObject } from '../../basecomponentmodel/DependencyObject';
import { DependencyProperty } from '../../basecomponentmodel/DependencyProperty';
import { DependencyPropertyChangedEventArgs } from '../../basecomponentmodel/DependencyPropertyChangedEventArgs';
import { INotifyPropertyChanged } from '../../basecomponentmodel/INotifyPropertyChanged';
import { IValueConverter } from '../../basecomponentmodel/IValueConverter';
import { onchange } from '../../basecomponentmodel/OnChange';
import { RuntimeStyleInfo } from '../../basecomponentmodel/RuntimeStyleInfo';
import { ObservableCollection } from '../../baseframework/collections';
import { RuntimeTypeInfoImpl } from '../../baseframework/ReflectionSupport';
import { TypeResolver } from '../../helpers/TypeResolver';
import { SubscriptionEvent } from '../../utils';
import { AllowToolTips, SortDirection, TextWrapping } from '../enums';
import { CellBase } from './CellBase';
import { ColumnLayout } from './ColumnLayout';
import { HorizontalAlignment, VerticalAlignment } from './ContainerEnums';
import { ColumnWidth } from './DataGridLengthModel';
import { DataTemplate } from './DataTemplate';
import { RowBase } from './RowBase';
import { XamGridCell, XamGridModel } from './XamGridModel';

/**
 * Column Base class for the xam grid column
 *
 * @export
 * @class XamGridColumnBaseModel
 * @extends {DependencyObject}
 * @implements {INotifyPropertyChanged}
 * @wType Infragistics.Controls.Grids.ColumnBase
 */
export class XamGridColumnBaseModel
  extends DependencyObject
  implements INotifyPropertyChanged
{
  /**
   * TagProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static TagProperty: DependencyProperty = new DependencyProperty(
    'Tag',
    null,
    null
  );

  /**
   * HeaderTextProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnBaseModel
   */
  public static HeaderTextProperty: DependencyProperty = new DependencyProperty(
    'HeaderText',
    '',
    null
  );

  /**
   * KeyProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnBaseModel
   */
  public static KeyProperty: DependencyProperty = new DependencyProperty(
    'Key',
    '',
    null
  );

  /**
   * VisibilityProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static VisibilityProperty: DependencyProperty = new DependencyProperty(
    'Visibility',
    true,
    null
  );

  PropertyChanged: SubscriptionEvent<
    (o: any, args: { PropertyName: string }) => void
  > = new SubscriptionEvent();

  /**
   * property to add a footer style
   *
   * @type {RuntimeStyleInfo}
   * @memberof XamGridColumnBaseModel
   */
  FooterStyle: RuntimeStyleInfo;

  /**
   * private field for the column layout
   *
   * @private
   * @type {ColumnLayout}
   * @memberof XamGridColumnBaseModel
   */
  private _layout: ColumnLayout;

  /**
   * Gets or sets the tag
   *
   * @type {unknown}
   * @memberof XamGridColumnBaseModel
   */
  @Dependency(XamGridColumnBaseModel.TagProperty)
  public Tag: unknown;

  /**
   * Gets or sets the visibility
   *
   * @type {boolean}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnBaseModel.VisibilityProperty)
  public Visibility: boolean;

  /**
   * Gets or sets the HeaderText
   *
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnBaseModel.HeaderTextProperty)
  public HeaderText: string;

  /**
   * Gets or sets the key
   *
   * @type {string}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnBaseModel.KeyProperty)
  public Key: string;

  /**
   * DataType property.
   *
   * @type {string}
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public DataType: 'string' | 'number' | 'date' | 'boolean' = 'string';

  /**
   * method call when the column layout is changed
   *
   * @memberof XamGridColumnBaseModel
   * @wMethod OnColumnLayoutChanged
   * @wNoMap
   */
  onColumnLayoutChanged() {}

  /**
   * XamGrid Column layout
   *
   * @memberof XamGridColumnBaseModel
   */
  get ColumnLayout(): ColumnLayout {
    return this._layout;
  }

  set ColumnLayout(value: ColumnLayout) {
    if (this._layout !== value) {
      this._layout = value;
      this.onColumnLayoutChanged();
    }
  }
}

/**
 * Base model class representing the column model.
 *
 * @export
 * @class XamGridColumnModel
 * @extends {DependencyObject}
 * @wType Infragistics.Controls.Grids.Column
 */
export class XamGridColumnModel extends XamGridColumnBaseModel {
  /**
   * AddNewRowCellStyleProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static AddNewRowCellStyleProperty: DependencyProperty =
    new DependencyProperty('AddNewRowCellStyle', null, null);

  /**
   * AddNewRowEditorTemplateHorizontalContentAlignmentProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static AddNewRowEditorTemplateHorizontalContentAlignmentProperty: DependencyProperty =
    new DependencyProperty(
      'AddNewRowEditorTemplateHorizontalContentAlignment',
      null,
      null
    );

  /**
   * AddNewRowEditorTemplateProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static AddNewRowEditorTemplateProperty: DependencyProperty =
    new DependencyProperty('AddNewRowEditorTemplate', null, null);

  /**
   * AddNewRowEditorTemplateVerticalContentAlignmentProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static AddNewRowEditorTemplateVerticalContentAlignmentProperty: DependencyProperty =
    new DependencyProperty(
      'AddNewRowEditorTemplateVerticalContentAlignment',
      null,
      null
    );

  /**
   * AddNewRowItemTemplateHorizontalContentAlignmentProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static AddNewRowItemTemplateHorizontalContentAlignmentProperty: DependencyProperty =
    new DependencyProperty(
      'AddNewRowItemTemplateHorizontalContentAlignment',
      null,
      null
    );

  /**
   * AddNewRowItemTemplateProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static AddNewRowItemTemplateProperty: DependencyProperty =
    new DependencyProperty('AddNewRowItemTemplate', null, null);

  /**
   * AddNewRowItemTemplateVerticalContentAlignmentProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static AddNewRowItemTemplateVerticalContentAlignmentProperty: DependencyProperty =
    new DependencyProperty(
      'AddNewRowItemTemplateVerticalContentAlignment',
      null,
      null
    );

  /**
   * AllowToolTipsProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static AllowToolTipsProperty: DependencyProperty =
    new DependencyProperty('AllowToolTips', AllowToolTips.Never, null);

  /**
   * FirstSortDirectionProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static FirstSortDirectionProperty: DependencyProperty =
    new DependencyProperty('FirstSortDirection', null, null);

  /**
   * FooterTextProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static FooterTextProperty: DependencyProperty = new DependencyProperty(
    'FooterText',
    '',
    XamGridColumnModel.FooterTextChangedCallback,
    new RuntimeTypeInfoImpl(String)
  );

  /**
   * GroupByHeaderCellStyleProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static GroupByHeaderCellStyleProperty: DependencyProperty =
    new DependencyProperty('GroupByHeaderCellStyle', null, null);

  /**
   * GroupByItemTemplateProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static GroupByItemTemplateProperty: DependencyProperty =
    new DependencyProperty('GroupByItemTemplate', null, null);

  /**
   * GroupByRowCellStyleProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static GroupByRowCellStyleProperty: DependencyProperty =
    new DependencyProperty('GroupByRowCellStyle', null, null);

  /**
   * `HeaderStyle` dependency property.
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public static HeaderStyleProperty: DependencyProperty =
    new DependencyProperty('HeaderStyle', null, null);

  /**
   * HeaderTextHorizontalAlignmentProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static HeaderTextHorizontalAlignmentProperty: DependencyProperty =
    new DependencyProperty('HeaderTextHorizontalAlignment', null, null);

  /**
   * HeaderTextVerticalAlignmentProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static HeaderTextVerticalAlignmentProperty: DependencyProperty =
    new DependencyProperty('HeaderTextVerticalAlignment', null, null);

  /**
   * MaximumWidthProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static MaximumWidthProperty: DependencyProperty =
    new DependencyProperty('MaximumWidth', null, null);

  /**
   * MergeCellStyleProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static MergeCellStyleProperty: DependencyProperty =
    new DependencyProperty('MergeCellStyle', null, null);

  /**
   * MergedItemTemplateProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static MergedItemTemplateProperty: DependencyProperty =
    new DependencyProperty('MergedItemTemplate', null, null);

  /**
   * MinimumWidthProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static MinimumWidthProperty: DependencyProperty =
    new DependencyProperty('MinimumWidth', null, null);

  /**
   * ToolTipContentTemplateProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static ToolTipContentTemplateProperty: DependencyProperty =
    new DependencyProperty('ToolTipContentTemplate', null, null);

  /**
   * ToolTipStyleProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static ToolTipStyleProperty: DependencyProperty =
    new DependencyProperty('ToolTipStyle', null, null);

  /**
   * ValueConverterParameterProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static ValueConverterParameterProperty: DependencyProperty =
    new DependencyProperty('ValueConverterParameter', null, null);

  /**
   * ValueConverterProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static ValueConverterProperty: DependencyProperty =
    new DependencyProperty('ValueConverter', null, null);

  /**
   * WidthProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof XamGridColumnModel
   */
  public static WidthProperty: DependencyProperty = new DependencyProperty(
    'Width',
    null,
    null
  );

  /**
   * IsReadOnlyProperty dependency property
   *
   * @static
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public static IsReadOnlyProperty = new DependencyProperty(
    'IsReadOnly',
    false,
    XamGridColumnModel.IsReadOnlyCallBack
  );

  /**
   * IsFilterableProperty dependency property
   *
   * @static
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public static IsFilterableProperty = new DependencyProperty(
    'IsFilterable',
    true,
    null
  );

  /**
   * Gets or sets allow tooltips
   *
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.AllowToolTipsProperty)
  public AllowToolTips: AllowToolTips;

  /**
   * Gets or sets the footer text
   *
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.FooterTextProperty)
  public FooterText: string;

  /**
   * Gets or sets the style to be used by the column header.
   *
   * @type {RuntimeStyleInfo}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.HeaderStyleProperty)
  public HeaderStyle: RuntimeStyleInfo;

  /**
   * Gets or sets the minimun width
   *
   * @type {*}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.MinimumWidthProperty)
  public MinimumWidth: any;

  /**
   * Gets or sets the width
   *
   * @type {ColumnWidth}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.WidthProperty)
  public Width: ColumnWidth;

  /**
   * Gets or sets the maximun width
   *
   * @type {*}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.MaximumWidthProperty)
  public MaximumWidth: any;

  /**
   * Gets or sets the header text horizontal alignment
   *
   * @type {HorizontalAlignment}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.HeaderTextHorizontalAlignmentProperty)
  public HeaderTextHorizontalAlignment: HorizontalAlignment;

  /**
   * Gets or sets the value converter
   *
   * @type {IValueConverter}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.ValueConverterProperty)
  public ValueConverter: IValueConverter;

  /**
   * Gets or set the value converter parameter
   *
   * @type {unknown}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.ValueConverterParameterProperty)
  public ValueConverterParameter: unknown;

  /**
   * Returns whether this model represents a a column group.
   *
   * @readonly
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public get IsGroupColumn() {
    return false;
  }

  /**
   * Check is the column is read only.
   *
   * @type {boolean}
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  @Dependency(XamGridColumnModel.IsReadOnlyProperty)
  public IsReadOnly: boolean;

  /**
   * Check if the column is filterable.
   *
   * @type {boolean}
   * @memberof XamGridColumnModel
   */
  @Dependency(XamGridColumnModel.IsFilterableProperty)
  public IsFilterable: boolean;
  /**
   * CalculatedWidth property.
   *
   * @type {string}
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public CalculatedWidth: string = '0';
  public ConditionalFormatCollection = new ConditionalFormatCollection();
  public FilterColumnSettings = new FilterColumnSettings();
  public FooterStyle: RuntimeStyleInfo = null;
  public CellStyle: RuntimeStyleInfo = null;
  public IsGroupable = false;
  public IsHideable = false;
  public IsFixable = true;
  public IsMovable = true;
  public IsResizable = true;
  public IsFixed = FixedState.NotFixed;
  public SortComparer: unknown = null;
  public ActualWidth = 0;
  /**
   * Check if the column is Editable.
   *
   * @type {string}
   * @memberof XamGridColumnModel
   * @wProperty IsEditable
   */
  public Editable = false;
  #_isReadOnly = false; // eslint-disable-line @typescript-eslint/naming-convention
  public HeaderTemplate: DataTemplate;
  /**
   * FilterTempalte property.
   *
   * @type {string}
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public FilterTemplate: DataTemplate;

  /**
   * Mobilize custom property.
   * Gets or sets if the column header should adjust the width property.
   *
   * @protected
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public AutoSizeHeader = true;

  /**
   * Default Silverlight value for VerticalContentAlignment is Center
   */
  public VerticalContentAlignment: VerticalAlignment = VerticalAlignment.Center;

  /**
   * Default GridColumn value for HorizontalContentAlignment is Left
   */
  public HorizontalContentAlignment: HorizontalAlignment =
    HorizontalAlignment.Left;

  /**
   * Check if the column is sortable
   * True by default
   * @wIgnore
   */
  protected _isSortable: boolean = true;

  /**
   * Flag to determine the sorting direction being used
   * @wIgnore
   */
  private _isSorted: SortDirection = SortDirection.None;

  /**
   * The parent of this column if any.
   * Usually this is the containing column group.
   */
  @onchange()
  public Parent: XamGridColumnModel | XamGridModel | null = null;

  /**
   * If there is a `Template` property in `HeaderStyle`, returns information
   * about such `Template`. Otherwise, returns `null`.
   *
   * @readonly
   * @type {*}
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public get TemplateInHeaderStyle(): any {
    /* eslint-disable @typescript-eslint/naming-convention */
    if (this.cachedTemplateInHeaderStyle != null) {
      return this.cachedTemplateInHeaderStyle;
    }

    const controlTemplate = this.HeaderStyle?.Setters.toArray().find(
      (x) => x.Property === 'Template'
    )?.Value as ControlTemplate;
    if (controlTemplate) {
      const ctModel = new controlTemplate.templateModelClass(this);
      const componentType = TypeResolver.getType(ctModel.AngularComponentId);
      this.cachedTemplateInHeaderStyle = {
        controlType: componentType,
        controlModel: ctModel,
      };
      return this.cachedTemplateInHeaderStyle;
    }

    return null;
  }

  /**
   * Gets the resolved grid column width
   *
   * @readonly
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public get WidthResolved() {
    if (!this.Width) {
      return this.ColumnLayout.ColumnWidthResolved;
    }
    return this.Width;
  }

  /**
   * Returns the current sort state of this column.
   *
   * @readonly
   * @memberof XamGridColumnModel
   */
  get IsSorted(): SortDirection {
    return this._isSorted;
  }
  /**
   * Sets a new sort state for this column.
   *
   * @readonly
   * @memberof XamGridColumnModel
   */
  set IsSorted(value: SortDirection) {
    if (value === this._isSorted) return;
    this._isSorted = value;
    if (!this.ColumnLayout.Grid.SortingSettings.SortedColumns.contains(this)) {
      this.ColumnLayout.Grid.SortingSettings.SortedColumns.add(this);
    }
  }

  /**
   * Returns the current is sortable state of this column.
   *
   * @readonly
   * @memberof XamGridColumnModel
   */
  get IsSortable(): boolean {
    return this._isSortable;
  }
  /**
   * Sets is sortable state for this column.
   *
   * @readonly
   * @memberof XamGridColumnModel
   */
  set IsSortable(value: boolean) {
    if (value === this._isSortable) return;
    this._isSortable = value;
  }

  /**
   * Footer operand used to display the footer text.
   *
   * @protected
   * @type {*}
   * @memberof XamGridColumnModel
   */
  footerOperand: any;

  /**
   * Stores the information about the `Template` in `HeaderStyle`.
   *
   * @private
   * @type {{controlType: any, controlModel: any}}
   * @memberof XamGridColumnModel
   */
  private cachedTemplateInHeaderStyle: { controlType: any; controlModel: any } =
    null;

  /**
   * Creates an instance of XamGridColumnModel.
   *
   * @memberof XamGridColumnModel
   */
  constructor() {
    super();
    this.CreateFooterOperand();
  }

  /**
   * Dynamically create a class for summaries operands. Accepts a string
   * as a binding to render in the "footer" part of the columns.
   *
   * @param {string} [text]
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  CreateFooterOperand(footerTemplate?: any): void {
    const klass = class {} as any;
    klass.prototype.operate = (arg1, arg2, arg3) => {
      /* istanbul ignore else */
      if (footerTemplate?.control.model instanceof FrameworkElement) {
        footerTemplate.control.model.refreshBindings();
      }
      return [
        {
          key: 'default', // eslint-disable-line @typescript-eslint/naming-convention
          label: '', // eslint-disable-line @typescript-eslint/naming-convention
          summaryResult: footerTemplate?.control.model.Text ?? this.FooterText, // eslint-disable-line @typescript-eslint/naming-convention
        },
      ];
    };
    this.footerOperand = klass;
  }
  /**
   * Callback function for `IsReadOnly` changes.
   *
   * @static
   * @param {DependencyObject} sender
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public static IsReadOnlyCallBack(
    sender: DependencyObject,
    args: DependencyPropertyChangedEventArgs
  ) {
    (sender as XamGridColumnModel).Editable = !args.NewValue;
  }

  /**
   * Callback function for `FooterText` changes.
   *
   * @static
   * @param {DependencyObject} sender
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  public static FooterTextChangedCallback(
    sender: DependencyObject,
    args: DependencyPropertyChangedEventArgs
  ): void {
    (sender as XamGridColumnModel).CreateFooterOperand();
  }

  /**
   *  Triggers the `PropertyChanged` subscription event
   *
   * @protected
   * @param {string} propertyName
   * @memberof XamGridColumnModel
   * @wIgnore
   */
  protected OnPropertyChanged(propertyName: string): void {
    this.PropertyChanged.fire([propertyName]);
  }

  GenerateCell(row: RowBase): CellBase {
    return this.GenerateDataCell(row);
  }

  GenerateDataCell(row: RowBase): CellBase {
    const cell = new XamGridCell(row, this);
    const cellType = () =>
      this.ColumnLayout.Grid.gridComponentInstance.grid?.getCellByColumn(
        cell.Row.Index,
        'data.' + this.Key
      );
    cell.Control =
      this.ColumnLayout.Grid.gridComponentInstance.getCellControlIfExists(
        cellType,
        cell
      );
    return cell;
  }
}
/**
 *  Enumeration to specify how a column is fixed
 *
 * @export
 * @enum {number}
 * @wEnum Infragistics.Controls.Grids.FixedState
 */
export enum FixedState {
  NotFixed,
  Left,
  Right,
}

/**
 *  Model for editable XamGrid columns
 *
 * @export
 * @class XamGridEditableColumnModel
 * @extends {XamGridColumnModel}
 * @wType Infragistics.Controls.Grids.EditableColumn
 */
export class XamGridEditableColumnModel extends XamGridColumnModel {}

/**
 * An alias for the XamGridColumnModel for API compatibility.
 *
 * @export
 * @class DataGridTemplateColumnModel
 * @extends {XamGridEditableColumnModel}
 * @wType Infragistics.Controls.Grids.TemplateColumn
 */
export class XamGridTemplateColumnModel extends XamGridEditableColumnModel {
  public EditorTemplate: DataTemplate;
  public ItemTemplate: DataTemplate;
  public FooterTemplate: any;
}

/**
 * Text column model.
 *
 * @export
 * @class DataGridTextColumnModel
 * @extends {XamGridEditableColumnModel}
 * @wType Infragistics.Controls.Grids.TextColumn
 */
export class XamGridTextColumnModel extends XamGridEditableColumnModel {
  public TextWrapping: TextWrapping = null;
  public FormatString: string = null;
  HorizontalContentAlignment = HorizontalAlignment.Left; // Default value for textColumns
}

/**
 * Checkbox column model.
 *
 * @export
 * @class DataGridCheckboxColumnModel
 * @extends {XamGridEditableColumnModel}
 * @wType Infragistics.Controls.Grids.CheckBoxColumn
 */
export class XamGridCheckboxColumnModel extends XamGridEditableColumnModel {
  public readonly DataType = 'boolean';
}

/**
 * Unbound column model.
 *
 * @export
 * @class DataGridUnboundColumnModel
 * @extends {XamGridEditableColumnModel}
 * @wType Infragistics.Controls.Grids.UnboundColumn
 */
export class XamGridUnboundColumnModel extends XamGridEditableColumnModel {
  /**
   * Key property.
   *
   * @memberof XamGridUnboundColumnModel
   */
  public Key: string;

  /**
   * ItemTemplate property.
   *
   * @memberof XamGridUnboundColumnModel
   */
  public ItemTemplate: DataTemplate = null;

  /**
   * EditorTemplate property.
   *
   * @memberof XamGridUnboundColumnModel
   */
  public EditorTemplate: DataTemplate = null;

  /**
   * Creates a new instance of XamGridUnboundColumnModel.
   *
   * @memberof XamGridUnboundColumnModel
   */
  constructor() {
    super();
    this.IsSortable = false;
  }
}

/**
 * Model representing a column group.
 *
 * @export
 * @class XamGridGroupColumnModel
 * @extends {XamGridColumnModel}
 * @wType Infragistics.Controls.Grids.GroupColumn
 */
export class XamGridGroupColumnModel extends XamGridColumnModel {
  /**
   * Internal Columns property
   * @wIgnore
   */
  protected _columns = new GroupColumnsCollection();

  /**
   * Returns whether the this model is a column group.
   *
   * @readonly
   * @memberof XamGridGroupColumnModel
   * @wIgnore
   */
  get IsGroupColumn() {
    return true;
  }

  /**
   * Returns whether this model represents a column group.
   *
   * @readonly
   * @memberof XamGridGroupColumnModel
   */
  get Columns() {
    return this._columns;
  }

  /**
   * Adds a column model to the column group model collection.
   *
   * @param {XamGridColumnModel} column
   * @memberof XamGridGroupColumnModel
   * @wIgnore
   */
  AddColumn(column: XamGridColumnModel) {
    column.ColumnLayout = this.ColumnLayout;
    this._columns.add(column);
  }
}

/**
 * Group Column collection class
 *
 * @export
 * @class GroupColumnsCollection
 * @extends {ObservableCollection<XamGridColumnModel>}
 * @wType Infragistics.Controls.Grids.GroupColumnsCollection
 */
export class GroupColumnsCollection extends ObservableCollection<XamGridColumnModel> {
  /**
   * Method to returns the column with a specify key
   *
   * @param {string} key
   * @return {*}
   * @memberof GroupColumnsCollection
   */
  getColumnByKey(key: string) {
    for (const column of this) {
      if (column.Key === key) {
        return column;
      }
    }
    return null;
  }

  getColumnByKeyDeep(key: string): {
    column: XamGridColumnModel;
    isRoot: boolean;
  } {
    const groupColumns = [];
    for (const column of this) {
      if (column.Key === key) {
        return { column, isRoot: false };
      }
      if (column instanceof XamGridGroupColumnModel) {
        groupColumns.push(column);
      }
    }

    for (const columnGroup of groupColumns) {
      let { column } = columnGroup.Columns.getColumnByKeyDeep(key);
      if (column) {
        return { column, isRoot: false };
      }
    }
    return { column: null, isRoot: false };
  }
}

/**
 *  Interface for conditional formatting rules
 *
 * @export
 * @interface IConditionalFormattingRule
 * @wInterface Infragistics.Controls.Grids.IConditionalFormattingRule
 */
export interface IConditionalFormattingRule {}

/**
 *  Collection of conditional formating rules
 *
 * @export
 * @class ConditionalFormatCollection
 * @extends {ObservableCollection<IConditionalFormattingRule>}
 * @wType Infragistics.Controls.Grids.ConditionalFormatCollection
 */
export class ConditionalFormatCollection extends ObservableCollection<IConditionalFormattingRule> {}

/**
 *  Settings for column filtering
 *
 * @export
 * @class FilterColumnSettings
 * @wType Infragistics.Controls.Grids.FilterColumnSettings
 */
export class FilterColumnSettings {
  FilterCellValue: unknown = null;
  FilteringOperand: FilteringOperand = null;
}

/**
 *  Base class for filtering operands
 *
 * @export
 * @abstract
 * @class FilteringOperand
 * @wType Infragistics.Controls.Grids.FilterOperand
 */
export abstract class FilteringOperand {
  abstract get operand(): any;
}

function applyIgnoreCase(s: string, ignoreCase: boolean): string {
  s = s ?? '';
  return ignoreCase ? `${s}`.toLowerCase() : s;
}

/**
 *  A class to represent the `contains` operand
 *
 * @export
 * @class ContainsOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.ContainsOperand
 */
export class ContainsOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'contains',
      isUnary: false,
      iconName: 'contains',
      logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
        const search = applyIgnoreCase(searchVal, ignoreCase);
        target = applyIgnoreCase(target, ignoreCase);
        return target.indexOf(search) !== -1;
      },
    };
  }
}

/**
 * A class representing the `doesNotContain` operand
 *
 * @export
 * @class DoesNotContainOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.DoesNotContainOperand
 */
export class DoesNotContainOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'doesNotContain',
      isUnary: false,
      iconName: 'does-not-contain',
      logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
        const search = applyIgnoreCase(searchVal, ignoreCase);
        target = applyIgnoreCase(target, ignoreCase);
        return target.indexOf(search) === -1;
      },
    };
  }
}

/**
 * A class representing the `startsWith` operand
 *
 * @export
 * @class StartsWithOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.StartsWithOperand
 */
export class StartsWithOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'startsWith',
      isUnary: false,
      iconName: 'starts-with',
      logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
        const search = applyIgnoreCase(searchVal, ignoreCase);
        target = applyIgnoreCase(target, ignoreCase);
        return target.startsWith(search);
      },
    };
  }
}

/**
 * A class representing the `doesNotStartWith` operand
 *
 * @export
 * @class DoesNotStartWithOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.DoesNotStartWithOperand
 */
export class DoesNotStartWithOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'Does Not Start With',
      isUnary: false,
      iconName: 'does-not-start-with',
      logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
        const search = applyIgnoreCase(searchVal, ignoreCase);
        target = applyIgnoreCase(target, ignoreCase);
        return !target.startsWith(search);
      },
    };
  }
}

/**
 * A class representing the `endsWith` operand
 *
 * @export
 * @class EndsWithOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.EndsWithOperand
 */
export class EndsWithOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'endsWith',
      isUnary: false,
      iconName: 'ends-with',
      logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
        const search = applyIgnoreCase(searchVal, ignoreCase);
        target = applyIgnoreCase(target, ignoreCase);
        return target.endsWith(search);
      },
    };
  }
}

/**
 * A class representing the `doesNotEndWith` operand
 *
 * @export
 * @class DoesNotEndWithOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.DoesNotEndWithOperand
 */
export class DoesNotEndWithOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'Does Not End With',
      isUnary: false,
      iconName: 'does-not-end-with',
      logic: (target: string, searchVal: string, ignoreCase?: boolean) => {
        const search = applyIgnoreCase(searchVal, ignoreCase);
        target = applyIgnoreCase(target, ignoreCase);
        return !target.endsWith(search);
      },
    };
  }
}

/**
 * A class representing the `equals` operand
 *
 * @export
 * @class EqualsOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.EqualsOperand
 */
export class EqualsOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'equals',
      isUnary: false,
      iconName: 'equals',
      logic: (target: number, searchVal: number) => target === searchVal,
    };
  }
}

/**
 * A class representing the `notEqual` operand
 *
 * @export
 * @class NotEqualsOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.NotEqualsOperand
 */
export class NotEqualsOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'doesNotEqual',
      isUnary: false,
      iconName: 'not-equal',
      logic: (target: number, searchVal: number) => target !== searchVal,
    };
  }
}

/**
 * A class representing the `greaterThan` operand
 *
 * @export
 * @class GreaterThanOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.GreaterThanOperand
 */
export class GreaterThanOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'greaterThan',
      isUnary: false,
      iconName: 'greater-than',
      logic: (target: number, searchVal: number) => target > searchVal,
    };
  }
}

/**
 * A class representing the `greaterThanOrEqualTo` operand
 *
 * @export
 * @class GreaterThanOrEqualOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.GreaterThanOrEqualOperand
 */
export class GreaterThanOrEqualOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'greaterThanOrEqualTo',
      isUnary: false,
      iconName: 'greater-than-or-equal',
      logic: (target: number, searchVal: number) => target >= searchVal,
    };
  }
}

/**
 * A class representing the `lessThan` operand
 *
 * @export
 * @class LessThanOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.LessThanOperand
 */
export class LessThanOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'lessThan',
      isUnary: false,
      iconName: 'less-than',
      logic: (target: number, searchVal: number) => target < searchVal,
    };
  }
}

/**
 * A class representing the `lessThanOrEqualTo` operand
 *
 * @export
 * @class LessThanOrEqualOperand
 * @extends {FilteringOperand}
 * @wType Infragistics.Controls.Grids.LessThanOrEqualOperand
 */
export class LessThanOrEqualOperand extends FilteringOperand {
  get operand() {
    return {
      name: 'lessThanOrEqualTo',
      isUnary: false,
      iconName: 'less-than-or-equal',
      logic: (target: number, searchVal: number) => target <= searchVal,
    };
  }
}

/**
 * A class representing the `BetweenXandYConditionalFormatRule`
 *
 * @export
 * @class BetweenXandYConditionalFormatRule
 * @wType Infragistics.Controls.Grids.BetweenXandYConditionalFormatRule
 */
export class BetweenXandYConditionalFormatRule {
  IsInclusive = true;
  UpperBound: number;
  LowerBound: number;
  StyleToApply = {};

  callback(value: number) {
    if (this.IsInclusive) {
      return value >= this.LowerBound && value <= this.UpperBound;
    }
    return value > this.LowerBound && value < this.UpperBound;
  }
}

/**
 * A class representing the `LessThanConditionalFormatRule`
 *
 * @export
 * @class LessThanConditionalFormatRule
 * @wType Infragistics.Controls.Grids.LessThanConditionalFormatRule
 */
export class LessThanConditionalFormatRule {
  Value: number;
  StyleToApply = {};

  callback(value: number) {
    return value < this.Value;
  }
}

/**
 * A class representing the `GreaterThanConditionalFormatRule`
 *
 * @export
 * @class GreaterThanConditionalFormatRule
 * @wType Infragistics.Controls.Grids.GreaterThanConditionalFormatRule
 */
export class GreaterThanConditionalFormatRule {
  Value: number;
  StyleToApply = {};

  callback(value: number) {
    return value > this.Value;
  }
}

result-matching ""

    No results matching ""