projects/wms-framework/src/lib/models/controls/CellBaseCollectionModel.ts
Collection of CellBase for the xamGrid
Properties |
|
Methods |
|
constructor(columns: any, row: any)
|
Creates an instance of CellBaseCollection. |
Private _auxColumns |
Type : Map<XamGridColumnBaseModel | CellBase>
|
Auxiliar collection of columns |
Private _columns |
Type : ColumnBaseCollection
|
private collection of columns |
Private _row |
Type : any
|
private collection of rows |
Public AddNewItem |
Type : SubscriptionEvent<void>
|
Default value : new SubscriptionEvent()
|
Inherited from
ObservableCollection
|
Defined in
ObservableCollection:888
|
Event AddNewItem have changed. |
Public CollectionChanged |
Type : SubscriptionEvent<void>
|
Default value : new SubscriptionEvent()
|
Inherited from
ObservableCollection
|
Defined in
ObservableCollection:878
|
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
|
Defined in
ObservableCollection:869
|
Event to indicate that a property have changed. |
Protected _internalArray |
Type : T[]
|
Default value : []
|
Inherited from
SimpleList
|
Defined in
SimpleList:276
|
getCellByKey | ||||||
getCellByKey(keyColumn: string | XamGridColumnModel)
|
||||||
Method to returns the Cell with a specify key
Parameters :
Returns :
any
|
getColumnFromDictionary | ||||||
getColumnFromDictionary(column: XamGridColumnModel)
|
||||||
Gets an item from the collection by its index.
Parameters :
Returns :
any
|
getItem | ||||||
getItem(index: number)
|
||||||
Inherited from
SimpleList
|
||||||
Defined in
SimpleList:102
|
||||||
Gets an item from the collection by its index.
Parameters :
Returns :
any
|
getKey | ||||||
getKey(item: any)
|
||||||
Gets the key from an item.
Parameters :
Returns :
string | null
|
registerCellFromUI | ||||||||||||
registerCellFromUI(item: any, row: RowBase, Columns: ColumnBaseCollection)
|
||||||||||||
Register a new cell that comes from the UI.
Parameters :
Returns :
CellBase
|
add | ||||||
add(value: T)
|
||||||
Inherited from
SimpleList
|
||||||
Defined in
SimpleList:995
|
||||||
Adds the given element at the end of the collection.
Parameters :
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
|
Defined in
ObservableCollection:1066
|
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 :
Returns :
void
|
Protected onCollectionChanged | ||||||
onCollectionChanged(info: CollectionChangeInfo)
|
||||||
Inherited from
ObservableCollection
|
||||||
Defined in
ObservableCollection:1078
|
||||||
Trigger a
Parameters :
Returns :
void
|
Protected onPropertyChanged | ||||||
onPropertyChanged(info: literal type)
|
||||||
Inherited from
ObservableCollection
|
||||||
Defined in
ObservableCollection:1090
|
||||||
Trigger a
Parameters :
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 :
Returns :
boolean
{boolean} |
removeAt | ||||||
removeAt(index: number)
|
||||||
Inherited from
SimpleList
|
||||||
Defined in
SimpleList:977
|
||||||
Removes the element at the given position.
Parameters :
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 :
Returns :
void
|
silentAddRange | ||||||
silentAddRange(range: Iterable<T>)
|
||||||
Inherited from
ObservableCollection
|
||||||
Defined in
ObservableCollection:1013
|
||||||
Adds elements of an iterable to the list
Parameters :
Returns :
void
|
addRange | ||||||
addRange(range: Iterable<T>)
|
||||||
Inherited from
SimpleList
|
||||||
Defined in
SimpleList:452
|
||||||
Adds elements of an iterable to the list
Parameters :
Returns :
void
|
contains | ||||||
contains(value: T)
|
||||||
Inherited from
SimpleList
|
||||||
Defined in
SimpleList:410
|
||||||
Check if a value is contained in the list
Parameters :
Returns :
boolean
|
copyTo | |||||||||
copyTo(target: T[], index: number)
|
|||||||||
Inherited from
SimpleList
|
|||||||||
Defined in
SimpleList:513
|
|||||||||
Copies the list to a target array
Parameters :
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 :
Returns :
void
|
indexOf | ||||||
indexOf(value: T)
|
||||||
Inherited from
SimpleList
|
||||||
Defined in
SimpleList:343
|
||||||
Index of value in list
Parameters :
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 :
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 :
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 {
XamGridColumnBaseModel,
XamGridColumnModel,
} from './XamGridColumnModel';
import { CellBase } from './CellBase';
import { ColumnBaseCollection, XamGridCell } from './XamGridModel';
import { RowBase } from './RowBase';
import { ObservableCollection } from '../../baseframework/collections';
/**
* Collection of CellBase for the xamGrid
*
* @export
* @class CellBaseCollectionModel
* @extends {ObservableCollection<XamGridCell>}
* @wType Infragistics.Controls.Grids.Primitives.CellBaseCollection
*/
export class CellBaseCollectionModel extends ObservableCollection<CellBase> {
/**
* private collection of rows
*
* @private
* @type {*}
* @memberof CellBaseCollectionModel
*/
private _row: any;
/**
* private collection of columns
*
* @private
* @type {ColumnBaseCollection}
* @memberof CellBaseCollectionModel
*/
private _columns: ColumnBaseCollection;
/**
* Auxiliar collection of columns
*
* @private
* @type {Map<XamGridColumnBaseModel, CellBase>}
* @memberof CellBaseCollectionModel
*/
private _auxColumns: Map<XamGridColumnBaseModel, CellBase>;
/**
* Creates an instance of CellBaseCollection.
* @param {*} columns
* @param {*} row
* @memberof CellBaseCollectionModel
*/
constructor(columns: any, row: any) {
super();
this._row = row;
this._columns = columns;
this._auxColumns = new Map<XamGridColumnBaseModel, CellBase>();
}
/**
* Method to returns the Cell with a specify key
*
* @param {string} keyColumn
* @return {*}
* @memberof GroupColumnsCollection
*/
getCellByKey(keyColumn: string | XamGridColumnModel): any {
let column = keyColumn;
if (typeof column === 'string') {
let { column: columnTmp } = this._columns.getColumnByKeyDeep(column);
column = columnTmp;
}
if (column instanceof XamGridColumnModel) {
return this.getColumnFromDictionary(column);
}
return null;
}
/**
* Gets an item from the collection by its index.
*
* @param {number} index
* @type {any}
* @memberof CellBaseCollectionModel
* @wMethod GetItem
*/
getItem(index: number): any {
const column = this._columns.DataColumns.getItem(index);
return this.getCellByKey(column);
}
/**
* Gets an item from the collection by its index.
*
* @param {XamGridColumnModel} column
* @type {any}
* @memberof CellBaseCollectionModel
*/
getColumnFromDictionary(column: XamGridColumnModel): any {
if (this._auxColumns.has(column)) {
return this._auxColumns.get(column);
}
const cellBase = column.GenerateCell(this._row);
this.add(cellBase);
this._auxColumns.set(column, cellBase);
return cellBase;
}
/**
* Register a new cell that comes from the UI.
*
* @param {any} item
* @param {RowBase} row
* @param {ColumnBaseCollection} Columns
* @type {CellBase}
* @memberof CellBaseCollectionModel
*/
registerCellFromUI(
item: any,
row: RowBase,
Columns: ColumnBaseCollection
): CellBase {
const key = this.getKey(item);
const { column, isRoot } = Columns.getColumnByKeyDeep(key);
if (column) {
if (this._auxColumns.has(column)) {
return this._auxColumns.get(column);
}
const currentCell = row.Cells.getCellByKey(key);
if (currentCell) {
this._auxColumns.set(column, currentCell);
if (isRoot) {
this.add(currentCell);
}
return currentCell;
}
const cell = new XamGridCell(row, column);
this._auxColumns.set(column, cell);
if (isRoot) {
this.add(cell);
}
return cell;
}
console.log('this is not a valid column');
}
/**
* Gets the key from an item.
*
* @param {any} item
* @type {string | null}
* @memberof CellBaseCollectionModel
*/
getKey(item: any): string | null {
let columnString = '';
if (item.column?.field) {
columnString = item.column?.field;
} else if (item._columnField) {
columnString = item._columnField;
}
const key = columnString.substring(5, columnString.length);
return key ?? '';
}
}