File

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

Description

Group Column collection class

Extends

ObservableCollection

Index

Properties
Methods

Properties

Public AddNewItem
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Inherited from ObservableCollection

Event AddNewItem have changed.

Public CollectionChanged
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Inherited from ObservableCollection

Event to indicate that the collection have changed.

Protected Static interfacesInitialized
Default value : false
Inherited from SimpleList
Defined in SimpleList:862

Flag to indicate if supported interfaces have been initialized.

Public PropertyChanged
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Inherited from ObservableCollection

Event to indicate that a property have changed.

Protected _internalArray
Type : T[]
Default value : []
Inherited from SimpleList
Defined in SimpleList:276

Methods

getColumnByKey
getColumnByKey(key: string)

Method to returns the column with a specify key

Parameters :
Name Type Optional
key string No
Returns : any
getColumnByKeyDeep
getColumnByKeyDeep(key: string)
Parameters :
Name Type Optional
key string No
Returns : literal type
add
add(value: T)
Inherited from SimpleList
Defined in SimpleList:995

Adds the given element at the end of the collection.

Parameters :
Name Type Optional
value T No
Returns : void
clear
clear()
Inherited from SimpleList
Defined in SimpleList:1031

Removes all elements from the collection.

Returns : void
Protected clearItems
clearItems()
Inherited from ObservableCollection

Removes all elements from the collection.

Returns : void
Protected Static initializeSupportedInterfaces
initializeSupportedInterfaces()
Inherited from SimpleList
Defined in SimpleList:913

Initialize the interfaces supported by this collection.

Returns : void
insert
insert(index: number, value: T)
Inherited from SimpleList
Defined in SimpleList:937

Inserts a new element at the specified position.

Parameters :
Name Type Optional
index number No
value T No
Returns : void
Protected onCollectionChanged
onCollectionChanged(info: CollectionChangeInfo)
Inherited from ObservableCollection

Trigger a CollectionChanged event.

Parameters :
Name Type Optional
info CollectionChangeInfo No
Returns : void
Protected onPropertyChanged
onPropertyChanged(info: literal type)
Inherited from ObservableCollection

Trigger a PropertyChanged event.

Parameters :
Name Type Optional
info literal type No
Returns : void
remove
remove(value: T)
Inherited from SimpleList
Defined in SimpleList:955

Removes the first element from the collection which matches the given value.

Parameters :
Name Type Optional
value T No
Returns : boolean

{boolean}

removeAt
removeAt(index: number)
Inherited from SimpleList
Defined in SimpleList:977

Removes the element at the given position.

Parameters :
Name Type Optional
index number No
Returns : void
setItem
setItem(index: number, value: T)
Inherited from SimpleList
Defined in SimpleList:1047

Replace the element at the given position with the given element.

Parameters :
Name Type Optional
index number No
value T No
Returns : void
silentAddRange
silentAddRange(range: Iterable<T>)
Inherited from ObservableCollection

Adds elements of an iterable to the list

Parameters :
Name Type Optional
range Iterable<T> No
Returns : void
addRange
addRange(range: Iterable<T>)
Inherited from SimpleList
Defined in SimpleList:452

Adds elements of an iterable to the list

Parameters :
Name Type Optional
range Iterable<T> No
Returns : void
contains
contains(value: T)
Inherited from SimpleList
Defined in SimpleList:410

Check if a value is contained in the list

Parameters :
Name Type Optional
value T No
Returns : boolean
copyTo
copyTo(target: T[], index: number)
Inherited from SimpleList
Defined in SimpleList:513

Copies the list to a target array

Parameters :
Name Type Optional
target T[] No
index number No
Returns : void
forEach
forEach(action: (e: T) => void)
Inherited from SimpleList
Defined in SimpleList:439

Performs an action on each element of the list

Parameters :
Name Type Optional
action function No
Returns : void
getItem
getItem(index: number)
Inherited from SimpleList
Defined in SimpleList:323
Parameters :
Name Type Optional
index number No
Returns : T
indexOf
indexOf(value: T)
Inherited from SimpleList
Defined in SimpleList:343

Index of value in list

Parameters :
Name Type Optional
value T No
Returns : any
insertRange
insertRange(position: number, range: Iterable<T>)
Inherited from SimpleList
Defined in SimpleList:466

Inserts elements of an interable to the list in a position

Parameters :
Name Type Optional
position number No
range Iterable<T> No
Returns : void
Public removeAll
removeAll(predicate: (e: T) => void)
Inherited from SimpleList
Defined in SimpleList:527

Removes all elements from the collection by a predicate

Parameters :
Name Type Optional
predicate function No
Returns : number
sort
sort()
Inherited from SimpleList
Defined in SimpleList:479

Sorts the list

Returns : any
Public toArray
toArray()
Inherited from SimpleList
Defined in SimpleList:545

Converts the list to an array

Returns : {}
()
Inherited from SimpleList
Defined in SimpleList:549
Returns : Iterator<T, any, undefined>
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 ""