File

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

Description

BindableItemCollection class

Implements

ICollectionBase INotifyCollectionChanged

Index

Properties
Methods
Accessors

Constructor

constructor(owner: IProvideDataItems<T>)

Creates an instance of BindableItemCollection.

Parameters :
Name Type Optional
owner IProvideDataItems<T> No

Properties

Protected _owner
Type : IProvideDataItems<T>

Owner of the data that the collection manipulates.

CollectionChanged
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()

Event that handles the change of the collection

internalArray
Type : T[]

Internal array used in case the used needs a array instead of the current class

PropertyChanged
Type : SubscriptionEvent<void>

Event that gets fired when a property changes.

Methods

add
add(item: any)

Add an item in the owner of the data

Parameters :
Name Type Optional
item any No
Returns : void
addItemSilently
addItemSilently(index: number, value: T)

To Implement

Parameters :
Name Type Optional
index number No
value T No
Returns : void
clear
clear()

To implement

Returns : void
contains
contains(value: T)

To implement

Parameters :
Name Type Optional
value T No
Returns : boolean

{boolean}

copyTo
copyTo(target: T[], index: number)

To implement

Parameters :
Name Type Optional
target T[] No
index number No
Returns : void
getItem
getItem(index: number)

Get an item from the owner of the data

Parameters :
Name Type Optional
index number No
Returns : any

{*}

indexOf
indexOf(value: T)

To implement

Parameters :
Name Type Optional
value T No
Returns : number

{number}

insert
insert(index: number, value: T)

Insert an element in the data owner in a specific index.

Parameters :
Name Type Optional
index number No
value T No
Returns : void
remove
remove(value: T)

Remove an element in the data owner.

Parameters :
Name Type Optional
value T No
Returns : boolean

{boolean}

removeAt
removeAt(index: number)

To implement

Parameters :
Name Type Optional
index number No
Returns : void
removeItemSilently
removeItemSilently(index: number)

To implement

Parameters :
Name Type Optional
index number No
Returns : void
resetItemsSilently
resetItemsSilently(index: number)

To implement

Parameters :
Name Type Optional
index number No
Returns : void
setItem
setItem(index: number, value: T)

To implement

Parameters :
Name Type Optional
index number No
value T No
Returns : void
sort
sort()

To implement

Returns : any
sort
sort(comparer: IComparer<T>)
Parameters :
Name Type Optional
comparer IComparer<T> No
Returns : any
sort
sort(comparer?: any)
Parameters :
Name Type Optional
comparer any Yes
Returns : any
()

Iterator of the iterable class

Returns : Iterator<T, any, undefined>

{Iterator<T, any, undefined>}

Accessors

count
getcount()

Gets the count of the datasets from the datacount

Returns : number
import {
  CollectionChangeInfo,
  IComparer,
  INotifyCollectionChanged,
} from '../../baseframework/collections';
import { SubscriptionEvent } from '../../utils/SubscriptionEvent';
import { ICollectionBase } from './ICollectionBase';
import { IProvideDataItems } from './IProvideDataItems';

/**
 * BindableItemCollection class
 *
 * @export
 * @class BindableItemCollection
 * @implements {ICollectionBase<T>}
 * @implements {INotifyCollectionChanged}
 * @template T
 * @wType Infragistics.Collections.BindableItemCollection`1
 */
export class BindableItemCollection<T>
  implements ICollectionBase<T>, INotifyCollectionChanged
{
  /**
   * Owner of the data that the collection manipulates.
   *
   * @protected
   * @type {IProvideDataItems<T>}
   * @memberof BindableItemCollection
   */
  protected _owner: IProvideDataItems<T>;

  /**
   * Creates an instance of BindableItemCollection.
   * @param {IProvideDataItems<T>} owner
   * @memberof BindableItemCollection
   */
  constructor(owner: IProvideDataItems<T>) {
    this._owner = owner;
  }

  /**
   * Event that gets fired when a property changes.
   *
   * @memberof BindableItemCollection
   * @wIgnore
   */
  PropertyChanged: SubscriptionEvent<
    (o: any, args: { PropertyName: string }) => void
  >;

  /**
   * To Implement
   *
   * @param {number} index
   * @param {T} value
   * @memberof BindableItemCollection
   * @wMethod AddItemSilently
   * @wNoMap
   */
  addItemSilently(index: number, value: T): void {
    throw new Error('Method not implemented.');
  }

  /**
   * To implement
   *
   * @param {number} index
   * @memberof BindableItemCollection
   * @wMethod removeItemSilently
   * @wNoMap
   */
  removeItemSilently(index: number): void {
    throw new Error('Method not implemented.');
  }

  /**
   * To implement
   *
   * @param {number} index
   * @memberof BindableItemCollection
   * @wMethod ResetItemsSilently
   * @wNoMap
   */
  resetItemsSilently(index: number): void {
    throw new Error('Method not implemented.');
  }

  /**
   * To implement
   *
   * @param {number} index
   * @param {T} value
   * @memberof BindableItemCollection
   */
  setItem(index: number, value: T) {
    throw new Error('Method not implemented.');
  }

  /**
   * To implement
   *
   * @param {T} value
   * @return {*}  {number}
   * @memberof BindableItemCollection
   * @wMethod IndexOf
   * @wNoMap
   */
  indexOf(value: T): number {
    throw new Error('Method not implemented.');
  }

  /**
   * Insert an element in the data owner in a specific index.
   *
   * @param {number} index
   * @param {T} value
   * @memberof BindableItemCollection
   * @wMethod Insert
   */
  insert(index: number, value: T) {
    this._owner.InsertItem(index, value);
  }

  /**
   * To implement
   *
   * @param {number} index
   * @memberof BindableItemCollection
   * @wMethod RemoveAt
   * @wNoMap
   */
  removeAt(index: number) {
    throw new Error('Method not implemented.');
  }

  /**
   * To implement
   *
   * @memberof BindableItemCollection
   */
  sort();
  sort(comparer: IComparer<T>);
  sort(comparer?: any): any {
    throw new Error('Method not implemented.');
  }

  /**
   * To implement
   *
   * @memberof BindableItemCollection
   * @wMethod Clear
   * @wNoMap
   */
  clear(): void {
    // we need to implement this method to make the collection work
  }

  /**
   * To implement
   *
   * @param {T} value
   * @return {*}  {boolean}
   * @memberof BindableItemCollection
   * @wMethod Contains
   * @wNoMap
   */
  contains(value: T): boolean {
    throw new Error('Method not implemented.');
  }

  /**
   * Remove an element in the data owner.
   *
   * @param {T} value
   * @return {*}  {boolean}
   * @memberof BindableItemCollection
   * @wMethod Remove
   */
  remove(value: T): boolean {
    return this._owner.RemoveItem(value);
  }

  /**
   * To implement
   *
   * @param {T[]} target
   * @param {number} index
   * @memberof BindableItemCollection
   * @wMethod CopyTo
   * @wNoMap
   */
  copyTo(target: T[], index: number): void {
    throw new Error('Method not implemented.');
  }

  /**
   * Iterator of the iterable class
   *
   * @return {*}  {Iterator<T, any, undefined>}
   * @memberof BindableItemCollection
   */
  [Symbol.iterator](): Iterator<T, any, undefined> {
    return this._owner.toArray()[Symbol.iterator]();
  }

  /**
   * Internal array used in case the used needs a array instead of the current class
   *
   * @type {T[]}
   * @memberof BindableItemCollection
   */
  internalArray: T[];

  /**
   * Event that handles the change of the collection
   *
   * @memberof BindableItemCollection
   */
  CollectionChanged: SubscriptionEvent<
    (e: any, args: CollectionChangeInfo) => void
  > = new SubscriptionEvent();

  /**
   * Add an item in the owner of the data
   *
   * @param {*} item
   * @memberof BindableItemCollection
   * @wMethod Add
   */
  add(item: any) {
    this._owner.add(item);
  }

  /**
   * Get an item from the owner of the data
   *
   * @param {number} index
   * @return {*}  {*}
   * @memberof BindableItemCollection
   * @wMethod GetItem
   */
  getItem(index: number): any {
    return this._owner.GetDataItem(index);
  }

  /**
   * Gets the count of the datasets from the datacount
   *
   * @readonly
   * @type {number}
   * @memberof BindableItemCollection
   * @wProperty Count
   */
  get count(): number {
    let result = 0;
    if (this._owner != null) {
      result = this._owner.DataCount;
    }
    return result;
  }
}

result-matching ""

    No results matching ""