UNPKG

@cute-dw/core

Version:

This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need

1,028 lines 65.4 kB
import { HttpErrorResponse } from "@angular/common/http"; import { Observable } from "rxjs"; import { DwControlProperties, DataStoreOptions, DwObject, BufferType, ItemStatus, SaveAsType, DwBandType } from "./DataStoreOptions"; import { HttpService } from "../services/http.service"; import { ResultCode } from "../util/enum/ResultCode"; import { IDataStore } from "./IDataStore"; import { CodeTableItem } from "./TableColumn"; import { Decimal } from "../util/type/Decimal"; import { DateTime } from "../util/type/DateTime"; import { Time } from "../util/type/Time"; import { DwDbmsErrorEvent, DwItemChangedEvent, DwItemErrorEvent, DwRetrieveEndEvent, DwRetrieveStartEvent, DwRowChangedEvent, DwUpdateEndEvent, DwUpdateStartEvent } from "./events"; export declare const ROW_ID_KEY: string; export declare const ROW_STATUS_KEY: string; /** * A DataStore is a nonvisual DataWindow control. DataStores act just like DataWindow controls except that * many of the visual properties associated with DataWindow controls do not apply to DataStores. Because you can * print DataStores, **@cute-dw** provides some events and functions for DataStores that pertain to * the visual presentation of the data. * @version 1.0.0 * @author Alexander V. Strelkov <alv.strelkov@gmail.com> * @copyright © ALEXANDER STRELKOV 2022 * @license MIT * @see DataWindow */ export declare class DataStore<T extends Object> implements IDataStore<T> { private _data; private _params; private _filter; private _sort; private _lastFind; private _evalCache; private _config; private _service; private _controls; private _columns; private _groups; private _httpService; private _sharedMainDS; private _sharedChilds; private _selectedRows; private _newRowSet; private _originalsMap; private _rowIndexes; /** * Subscription to the changes that should trigger an update to the table's rendered rows, such * as filtering, sorting, pagination, or base data changes. */ private _dataStreamSubscription; /** Stream emitting rendering data to the table (depends on ordered data changes). */ private readonly dataStream$; private _loading; private _updating; private _currentRow; private _currentCol; private _lastRowID; private _getChangesTimestamp; private _creationStamp; private _UUID; private readonly createEvent$; private readonly dbCancelEvent$; private readonly dbErrorEvent$; private readonly dwErrorEvent$; private readonly httpErrorEvent$; private readonly itemChangedEvent$; private readonly itemErrorEvent$; private readonly retrieveEndEvent$; private readonly retrieveStartEvent$; private readonly rowChangedEvent$; private readonly updateEndEvent$; private readonly updateStartEvent$; private readonly setParams$; readonly onCreate: Observable<void>; readonly onDbCancel: Observable<void>; readonly onDbError: Observable<DwDbmsErrorEvent>; readonly onDwError: Observable<any>; readonly onHttpError: Observable<HttpErrorResponse>; readonly onItemChanged: Observable<DwItemChangedEvent>; readonly onItemError: Observable<DwItemErrorEvent>; readonly onRetrieveEnd: Observable<DwRetrieveEndEvent>; readonly onRetrieveStart: Observable<DwRetrieveStartEvent>; readonly onRowChanged: Observable<DwRowChangedEvent>; readonly onUpdateEnd: Observable<DwUpdateEndEvent>; readonly onUpdateStart: Observable<DwUpdateStartEvent>; readonly onSetParams: Observable<void>; /** * @constructor */ constructor(options?: DataStoreOptions, http?: Readonly<HttpService>); /** * Returns initialization status */ private get isInitialized(); /** * Creates an internal controls array */ private createControls; /** * Creates a new row object and initializes it * * @returns Empty row object */ private createRowObject; /** * Gets target DataStore (shared/Main) * @returns */ getMainDS(): DataStore<T>; /** * Reports if DataWindow/DataStore updateable or not * @returns boolean */ private isUpdateable; /** * Resets each group in the defined group list * @private */ private resetGroups; /** * Finds a group object by its name * @private */ private findGroup; /** * Resets the internal map of the DataWindow row's data indexes */ private resetRowIndexes; /** * */ private toLiteralValue; /** * Gets the value of specified control that must be a column or computed type * * @param context Data object * @param key Control's key * @returns Control's value * * @private */ private getControlValue; /** * Returns control object by its name or null if it was not found * @private */ private getControl; /** * Clears original value in the originals Map object * @param rowobj Row Object * @param column Column name or "*" for clear all values * @returns true/false * @private */ private clearOriginalValue; /** * Proxify decorator * @private */ private proxify; /** * Clears internal row buffers * @param clearPrimary {boolean} Clear or not Primary! buffer. Default is true * * @private */ private clearBuffers; /** * Fills internal primary row buffer * * @private */ private setData; /** * Gets an array of Table parameter objects * @private */ private getParams; /** * Gets an array of column objects * @private */ private getColumns; /** * Gets the key columns of the updatable table * @returns Array of `TableColumn` objects * @private */ private getKeyColumns; /** * Gets database column name for column object * @private */ private getColumnDbName; /** * Checks the column for it belonging to the main (updatable) table * @param column `TableColumn` object * @returns true/false * @private */ private isMainTableColumn; /** * Checks the column if it updatable now * @param column `TableColumn` object * @returns true/false * @private */ private isColumnUpdatable; /** * Gets auto synchronized column names * @param includeIdentity Include `identity` column or not * @returns Array of the column names * @private */ private getAutoSyncColumns; /** * Gets a column object by its name/index or `undefined` if the object was not found * @private */ private getColumnObject; /** * Gets a row buffer array of the specified type * @private */ private getBuffer; /** * Posts data of `Primary!` buffer to primary and secondary DataStore/DataWindow observers * @private */ private emitDataStream; /** * Emulates and posts an empty data array to observers. * This method was exposed to solve the screen gluch when generating group headers in the DataWindow (in @angular/material's table) * * @private */ private emitEmptyDataStream; /** * @private */ private createRpcRequestObject; /** * Gets an array of columns for the `WHERE` clause * @param obj Row object * @param forDelete `DELETE` statement/method will be used * @returns Array of the table columns that must participate in the `WHERE` clause * @private */ private getWhereClauseColumns; /** * Save original value(s) * @private */ private makeOriginals; /** * Gets current loading status * @readonly * @since 0.0.0 * @see {@link retrieve} */ get loading(): boolean; /** * Checks for any updates that may be pending * @readonly * @since 0.0.0 * @see {@link update} * @see {@link updating} */ get updatesPending(): boolean; /** * Gets current updating status * @readonly * @since 0.0.0 * @see {@link update} */ get updating(): boolean; /** * Gets the data from the primary buffer * @readonly * @since 0.0.0 */ get data(): T[]; /** * Gets the data stream as the Observable object * @readonly * @since 0.0.0 */ get dataStream(): Observable<T[]>; /** * Returns internal http service object * @since 0.0.0 */ get httpService(): Readonly<HttpService> | undefined; /** * Gets the current filter value * @since 0.0.0 * @see {@link applyFilter} */ get filterValue(): string; /** * Sets filter expression * @since 0.0.0 * @see {@link applyFilter} */ set filterValue(express: string | null); /** * Current sort value * @since 0.0.0 * @see {@link applySort} */ get sortValue(): string | null; /** * Specifies sort criteria for a DataWindow control or DataStore. * A DataStore object can have sort criteria specified as part of its definition. * Set `sortValue` overrides the definition, providing new sort criteria for the DataStore. * However, it does not actually sort the rows. Call the {@link applySort} method to perform the actual sorting. * @example * this.sortValue = "emp_name asc, div_code desc"; * this.sortValue = "upper(client_address)"; // ascending by default * this.sortValue = "article_title \t left(String(post_date,'yyyymmdd'),4) desc"; * this.applySort(); * @since 0.0.0 */ set sortValue(express: string | null); /** * Gets copy of configured Controls as a plain objects' array * @readonly * @since 0.0.0 */ get controls(): DwObject[]; /** * The number of milliseconds between the internal timer events. Default is 0 (disabled) */ get timerInterval(): number; /** * The unique UUID value of the last *create()* function invocation */ get creationStamp(): string; /** * Creates a DataWindow object using {@link DataStoreOptions} object. It fully substitutes the current internal structure of a DataStore object. * * @param options An object of `DataStoreOptions` class * @returns 1 if it succeeds and -1 if an error occurs. * @since 0.0.0 */ create(options: DataStoreOptions): ResultCode; /** * Obtains the copy of the configured Controls as a map (plain JavaScript) object or an array of the `DwObject` objects * * @param band Optional. DataWindow control's band type. Default is `all`. * @param asArray Optional. Set to _true_ if you want to return an array of the `DwObject` objects, else the method returns a map object. Default is _false_. * @returns Array of `DwObject` objects or the plain JavaScript object as a key/value dictionary * @since 0.0.0 */ getControls(band?: "all" | DwBandType, asArray?: boolean): { [name: string]: DwControlProperties; } | DwObject[]; /** * Sets HttpService object for retrieve/update data on remote server * @param httpSvc HttpService object (optional) * @since 0.0.0 */ setHttpService(httpSvc?: Readonly<HttpService>): ResultCode; /** * Gets row count in the primary buffer * @returns Row count * @since 0.0.0 * @see {@link deletedCount} * @see {@link filteredCount} */ rowCount(): number; /** * Gets row count in the deleted rows buffer * @returns Row count * @since 0.0.0 * @see {@link rowCount} * @see {@link filteredCount} * @see {@link modifiedCount} */ deletedCount(): number; /** * Reports the number of rows that have been modified but not updated in a DataWindow or DataStore. * @returns {number} The number of rows that have been modified in the primary and filrer buffer. * Returns 0 if no rows have been modified or if all modified rows have been updated in the database table. * @since 0.0.0 * @see {@link rowCount} * @see {@link deletedCount} */ modifiedCount(): number; /** * Gets row count in the filtered rows buffer * @returns Row count * @since 0.0.0 * @see {@link deletedCount} * @see {@link rowCount} */ filteredCount(): number; /** * Gets group count in the DataWindow/DataStore object * @since 0.0.0 * @returns Group count */ groupCount(): number; /** * Applies the contents of the DataWindow's edit control to the current item in the buffer of a DataWindow control or DataStore. * The data in the edit control must pass the validation rule for the column before it can be stored in the item. * @returns Returns 1 if it succeeds and -1 if it fails (for example, the data did not pass validation). * @since 0.0.0 */ acceptText(): ResultCode; /** * Reports the values of properties of a DataWindow object and controls within the DataWindow object. * Each column and graphic control in the DataWindow has a set of properties. You specify one or more * properties as a string, and `describe` returns the values of the properties. * @param propertylist A string list (array) of properties or Evaluate functions * @returns * Returns array of values that includes a primitive value for each property or Evaluate function. * If the property list contains only one item, `describe` returns single value. * `Describe` returns an `undefined` value if there is no value for a property. * `Describe` returns `null` for property if its value is not a primitive. * @since 0.0.0 * @see {@link modify} */ describe(...propertylist: string[]): any[] | any; /** * Modifies a DataWindow object by applying specifications, given as a list of instructions, that * change the DataWindow object's definition. * @param propertylist A string array whose items ara the specifications for the modification. * @returns Returns the empty string ("") if it succeeds and an error message if an error occurs. * @since 0.0.0 * @see {@link describe} */ modify(...propertylist: string[]): string; /** * Gets cloned value of the current config options * @returns DataStoreOptions * @since 0.0.0 */ getOptions(): DataStoreOptions; /** * Searches for the next break for the specified group. A group break occurs when the value in the column for the group changes. * `findGroupChange` reports the row that begins the next section. * @description * If the starting row begins a new section at the specified level, then that row is the one returned. * To continue searching for subsequent breaks, increment the starting row so that the search resumes with * the second row in the group. * @param row A value identifying the row at which you want to begin searching for the group break. * @param level The number of the group for which you are searching. Groups are numbered in the order in which you defined them. * The return value observes these rules based on the value of row. If the starting row is: * · _The first row in a group_, then `findGroupChange` returns the starting row number * · _A row within a group_, other than the last group, then `findGroupChange` returns the row number of the first row of the next group * · _A row in the last group_, other than the first row of the last group, then `findGroupChange` returns -1 * @returns * Returns the number of the row whose group column has a new value, meaning that it begins a new group. * Returns -1 if the value in the group column did not change and -100 if an error occurs. * @since 0.0.0 */ findGroupChange(row: number, level: number): number; /** * Recalculates the breaks in the grouping levels in a DataStore/DataWindow. * * @description * Use `groupCalc` to force the DataWindow object to recalculate the breaks in the grouping levels * after you have added or modified rows in a DataWindow. `groupCalc` does not sort the data before it * recalculates the breaks. Therefore, unless you populated the DataWindow in a sorted order, * call the {@link applySort} method to sort the data before you call `groupCalc`. * @returns Returns 1 if it succeeds and -1 if an error occurs. * @since 0.0.0 */ groupCalc(): ResultCode; /** * Gets array of DataStore groups * @returns Readonly array of DSRowGroup structures * @since 0.0.0 */ getGroups(): readonly DSRowGroup<T>[]; /** * Reports the number of the current row in a DataWindow control or DataStore object. * @returns Returns the number of the current row in dwcontrol. Returns -1 if no row is current * @since 0.0.0 */ getRow(): number; /** * Sets the current row in a DataWindow control or DataStore. * @param row The row you want to make current * @returns Returns 1 if it succeeds, 0 if the row is the current row indeed, and -1 if an error occurs. * @since 0.0.0 */ setRow(row: number): ResultCode; /** * Gets the row object of specified row's number * @param {number} row Optional row number. Default is the current row number in DataWindow/DataStore * @returns Row object or _null_ if the number of the `row` is invalid * @since 0.0.0 */ getRowObject(row?: number): Readonly<T> | null; /** * Gets an index of the row object in the `Primary!` buffer * @param oRow {any} Row object * @returns {number} Index (row number) value if the object was found in the DataStore's main buffer and * -1 if the object does not exist in the buffer * @since 0.0.0 */ indexOf(oRow: any): number; /** * Reports the next row and column that is required and contains a null value. * The method arguments that specify where to start searching also store the results of the search. * You can speed up the search by specifying that `findRequired` check only inserted and modified rows. * * @param bufferType A value indicating the DataWindow buffer you want to search for required columns. Valid buffers are: Primary! and Filter! * @param context (In/Out) Reference to an object of type {row:number, col:number, colname:string} * @param updateonly A value indicating whether you want to validate all rows and columns or only rows that have been inserted or modified * @returns Returns **1** if `findRequired` successfully checked the rows and **-1** if an error occurs * @since 0.0.0 */ findRequired(bufferType: BufferType, context: { row: number; col: number; colname: string; }, updateonly: boolean): ResultCode; /** * Reports whether the row has been newly inserted. * @param row Row number or object to check * @param bufferType Internal DataStore buffer type * @returns {boolean} Returns _true_ if the row is new and _false_ if it was retrieved from the database. * @see {@link isRowModified} * @since 0.0.0 */ isRowNew(row: Object | number, bufferType?: BufferType): boolean; /** * Reports whether the row has been modified * @param row Row number or object to check * @param dwbuffer Internal DataStore buffer type * @returns {boolean} true if the row has been modified and false if it has not. * @see {@link isRowNew} * @see {@link getNextModified} * @since 0.0.0 */ isRowModified(row: Object | number, dwbuffer?: BufferType): boolean; /** * Reports the next row that has been modified in the specified buffer * @param row A value identifying the row location after which you want to locate the modified row. To search from the beginning, specify **-1**. * @param dwbuffer A value of the `BufferType` enumerated datatype * @returns Returns the number of the first row that was modified after row in dwbuffer in dwcontrol. * Returns -1 if there are no modified rows after the specified row. * If any argument value is _null_ the method returns _null_. * @see {@link isRowModified} * @since 0.0.0 */ getNextModified(row: number, dwbuffer?: BufferType): number | null; /** * Gets count of table columns * @returns Number of columns * @since 0.0.0 */ columnCount(): number; /** * Gets column name by its index. * @param {number} index Column index * @returns Column name or empty string if column was not found * @see {@link columnCount} * @since 0.0.0 */ columnName(index?: number): string; /** * Sets the current column in a `DataWindow` control or `DataStore`. * * @param col The column you want to make current. Column can be a column number or a column name. * @returns Returns 1 if it succeeds and -1 if an error occurs. * If a column is less than 0 or greater than the number of columns - 1, `setColumn` fails. * @see {@link getColumn} * @since 0.0.0 */ setColumn(col: number | string): ResultCode; /** * Obtains the number of the current column. The current column is the column that has focus. * @returns Returns the number of the current column in dwcontrol. Returns -1 if no column is current * @see {@link setColumn} * @since 0.0.0 */ getColumn(): number; /** * Obtains the name of the current column. The current column is the column that has the focus. * @returns Returns the name of the current column in dwcontrol. Returns the empty string ("") if no column is current or if an error occurs. * @see {@link columnName} * @see {@link getColumnType} * @see {@link getColumnIndex} * @since 0.0.0 */ getColumnName(): string; /** * Obtains the column's data type by its index or name * @param col {number|string} Column identifier * @returns {string} Column's data type or "!" if column with specified name/index is not found * @see {@link getColumnName} * @since 0.0.0 */ getColumnType(col: number | string): string; /** * Obtains column's index by column's name * @param name {string} Name of the table column * @returns {number} Column's index if the specified `name` was found in the column's list, else `-1`. * @see {@link getColumnName} * @since 0.0.0 */ getColumnIndex(name: string): number; /** * Obtains the validation rule for a column in a DataWindow. * @param column The column for which you want the validation rule. Column can be a column number or a column name. * @returns Returns the validation rule for column in dwcontrol. Returns the empty string ("") if no validation criteria are defined for the column. * @see {@link setValidate} * @since 0.0.0 */ getValidate(column: number | string): string; /** * Sets the input validation rule for a column in a DataWindow control or DataStore. * * @param column The column for which you want to set the input validation rule. Column can be a column number or a column name. * @param rule A string whose value is the validation rule for validating the data. * @returns Returns 1 if it succeeds and -1 if an error occurs. * @see {@link getValidate} * @since 0.0.0 */ setValidate(column: number | string, rule: string): ResultCode; /** * Obtains the object of an item in a value list or _code table_ associated with a column in a DataWindow * @param column The column for which you want the item. Column can be a column number (integer) or a column name (string). * @param index The number of the item in the value list or the code table for the edit style. * @returns The item object identified by index in the value list. Returns _undefined_ if the index is not valid or the column does not have a value list or code table. * @see {@link getDisplayValue} * @see {@link getValueByCode} * @see {@link getValues} * @see {@link setValue} * @since 0.0.0 */ getValue(column: string | number, index: number): CodeTableItem | undefined; /** * Obtains the object value of an item in a value list or _code table_ associated with a column and code's value in a DataWindow * @param column The column for which you want the item. Column can be a column number (integer) or a column name (string). * @param data The value to search in the column's code table if it was defined * @returns The item object identified by code in the value list. Returns undefined if the value is not valid or the column does not have a value list or code table. * @see {@link getValue} * @see {@link getDisplayValue} * @since 0.0.0 */ getValueByCode(column: string | number, data: any): CodeTableItem | undefined; /** * Obtains the display value in the code table associated with the data value in the specified column. * @param column The column for which you want the code table display value. Column's value can be a text or column's definition number * @param data The key value to search the display value in the code table * @returns Display text for the column's value or value itself if it was not found in the column's value list or code table * @see {@link getValue} * @see {@link getValueByCode} * @since 0.0.0 */ getDisplayValue(column: string | number, data: string | number): string; /** * Obtains the values in the code table for the column. * @param column The column for which you want to get `CodeTableItem` items. Column can be a column number (integer) or a column name (string). * @returns `CodeTableItem` items array * @see {@link getValue} * @since 0.0.0 */ getValues(column: string | number): CodeTableItem[] | undefined; /** * Sets the value of an item in a value list or code table for a column in a DataWindow control or DataStore. * (A value list is called a code table when it has both display and data values.) `setValue` does not affect the data stored in the column. * @param column The column that contains the value list or code table. Column can be a column number or a column name. * @param index The number of the item in the value list or code table for which you want to set the value. * @param value CodeTable's item value * @returns Returns SUCCESS(1) if it succeeds and FAILURE(-1) if an error occurs. * @see {@link clearValues} * @see {@link getValue} * @since 0.0.0 */ setValue(column: string | number, index: number, value: CodeTableItem): ResultCode; /** * Deletes all the items from a value list or code table associated with a DataWindow column. * (A value list is called a code table when it has both display and data values.) * ClearValues does not affect the data stored in the column. * @param column The column whose value list you want to delete. * @returns Returns SUCCESS(1) if it succeeds and FAILURE(-1) if an error occurs. * The return value is usually not used. * @see {@link setValue} * @since 0.0.0 */ clearValues(column: string | number): ResultCode; /** * Determines if the specified `column` has a table of display values and corresponding data values * @param column Column's name or number * @returns _True_ if the column definition contains a code table structure, else returns _false_ */ hasCodeTable(column: string | number): boolean; /** * * @param row * @param delimiter * @returns */ getRowTitle(row: number | Object, delimiter?: string): string; /** * * @param row * @param delimiter * @returns */ getRowSubTitle(row: number | Object, delimiter?: string): string; /** * * @param row * @returns */ getRowAvatar(row: number | Object): string; /** * Clears all the data from a DataWindow control or DataStore object. * {@link reset} is not the same as deleting rows from the DataWindow object or * child DataWindow. {@link reset} affects the application only, not the database. * If you delete rows and then call the {@link update} method, the rows are deleted from * the database table associated with the DataWindow object. If you call {@link reset} and * then call {@link update}, no changes are made to the table. * @returns 1 if it succeeds and -1 if an error occurs. The return value is usually not used. * @see {@link resetUpdate} * @since 0.0.0 */ reset(): ResultCode; /** * Clears the update flags in the primary and filter buffers and empties the delete buffer of a DataWindow or DataStore. * When a row is changed, inserted, or deleted, its update flag is set, making it marked for update. * By default, the Update method turns these flags off. If you want to coordinate updates of more than * one DataWindow or DataStore, however, you can prevent Update from clearing the flags. Then, after you verify * that all the updates succeeded, you can call ResetUpdate for each DataWindow to clear the flags. * If one of the updates failed, you can keep the update flags, prompt the user to fix the problem, and * try the updates again. * You can find out which rows are marked for update with the GetItemStatus method. If a row is in the * delete buffer or if it is in the primary or filter buffer and has `NewModified!` or `DataModified!` status, * its update flag is set. After update flags are cleared, all rows have the status `NotModified!` or `New!` and * the delete buffer is empty * @returns Completetion code * @see {@link update} * @see {@link reset} * @since 0.0.0 */ resetUpdate(): ResultCode; /** * Shares data retrieved by one DataWindow control (or DataStore), which is referred to as the * primary DataWindow, with another DataWindow control (or DataStore), referred to as the secondary * DataWindow. * The controls do not share formatting; only the data is shared, including data in the primary buffer, * the delete buffer, the filter buffer, and the sort order. * * @param child The name of the secondary DataWindow with which `this` control will share the data. * @returns Returns 1 if it succeeds and -1 if an error occurs. * @see {@link shareDataOff} * @since 0.0.0 */ shareData(child: DataStore<T>): ResultCode; /** * Turns off the sharing of data buffers for a DataWindow control or DataStore. * When you call {@link shareDataOff} for a secondary DataWindow, that control no longer * contains data, but the primary DataWindow and other secondary controls are not affected. * When you call {@link shareDataOff} for the primary DataWindow, all secondary DataWindows are disconnected and * no longer contain data. * @returns Returns 1 if it succeeds, 0 if a DataStore was not previously shared, and -1 if an error occurs. * @see {@link shareData} * @since 0.0.0 */ shareDataOff(): ResultCode; /** * Checks whether the DataWindow is shared by any other DataStore/DataWindow object * @returns _true_ if the DataStore has any secondary DataStore/DataWindow that was shared with this DataStore object, else _false_ */ isShared(): boolean; /** * Copies a range of rows from one DataWindow control (or DataStore object) to another, or from one buffer to another within a single DataWindow control (or DataStore). * @param startrow The number of the first row you want to copy. * @param endrow The number of the last row you want to copy. * @param srcbuffer A value of the `BufferType` identifying the DataWindow buffer from which you want to copy rows. * @param target A reference to the DataWindow control or DataStore object to which you want to copy the rows. Target can be the same DataWindow (or DataStore) or another DataWindow (or DataStore) * @param beforerow The number of the row before which you want to insert the copied rows. To insert after the last row, use any value that is greater than the number of existing rows. * @param destbuffer A value of the `BufferType` enumerated datatype identifying the target DataWindow buffer for the copied rows. * @returns Returns 1 if it succeeds, 0 if nothing happens and -1 if an error occurs. * @see {@link rowsMove} * @see {@link rowsDiscard} * @since 0.0.0 */ rowsCopy(startrow: number, endrow: number, srcbuffer: BufferType, target: DataStore<T>, beforerow: number, destbuffer: BufferType): ResultCode; /** * Discards a range of rows in a DataWindow control. Once a row has been discarded using {@link rowsDiscard}, you cannot restore the row. * You have to retrieve it again from the database. * @param startrow The number of the first row you want to discard. * @param endrow The number of the last row you want to discard. * @param dwbuffer A value of the `BufferType` enumerated datatype * @returns Returns 1 if it succeeds, 0 if nothing was deleted and -1 if an error occurs. * @since 0.0.0 */ rowsDiscard(startrow: number, endrow: number, dwbuffer?: BufferType): ResultCode; /** * Clears a range of rows from one DataWindow control (or DataStore) and inserts them in another. * Alternatively, {@link rowsMove} moves rows from one buffer to another within a single DataWindow control * (or DataStore). * @param startrow The number of the first row you want to move. * @param endrow The number of the last row you want to move. * @param srcbuffer A value of the `BufferType` identifying the DataWindow buffer from which you want to move rows. * @param target A reference to the DataWindow control or DataStore object to which you want to move the rows. Target can be the same DataWindow (or DataStore) or another DataWindow (or DataStore) * @param beforerow The number of the row before which you want to insert the moved rows. To insert after the last row, use any value that is greater than the number of existing rows. * @param destbuffer A value of the `BufferType` enumerated datatype identifying the target DataWindow buffer for the moving rows. * @returns Returns 1 if it succeeds, 0 if nothing happens and -1 if an error occurs. * @see {@link rowsCopy} * @since 0.0.0 */ rowsMove(startrow: number, endrow: number, srcbuffer: BufferType, target: DataStore<T>, beforerow: number, destbuffer: BufferType): ResultCode; /** * Cancels the retrieval process in a DataWindow/DataStore object * @see {@link retrieve} * @since 0.0.0 */ dbCancel(): void; /** * Sets values for the table parameters and emit event onSetParams * @param vals Array of any values or an object who's each property key is the parameter's name (case sensitive). * @returns Success (1) when any or all parameter values was changed, 0 - if nothing happens, -1 if an error occurs * @since 0.0.0 */ setParams(vals: any[] | { [name: string]: any; }): ResultCode; /** * Retrieves rows from the database for a DataWindow control or DataStore. If arguments are included, * the argument values are used for the retrieval arguments in the SQL `SELECT` statement for the DataWindow * object or child DataWindow. * After rows are retrieved, the DataWindow object's filter is applied. Therefore, any retrieved rows that * do not meet the filter criteria are immediately moved to the filter buffer and are not included in the * return count. * @param {...any} args One or more values that you want to use as retrieval arguments * @returns {Promise} Promise of the row count retrieved, or -1 if any error occurs * @see {@link dbCancel} * @since 0.0.0 */ retrieve(...args: any): Promise<number>; /** * Accesses the database to retrieve values for all columns that can be updated and refreshes all timestamp columns in a row in a DataWindow control or DataStore. The values from the database are redisplayed in the row. * @param row A value identifying the row to reselect * @returns An object of `Promise` type that returns 1 if it is successful and -1 if the row cannot be reselected (for example, the DataWindow object cannot be updated or the row was deleted by another user) * @since 0.0.0 * @see {@link reselectRows} */ reselectRow(row: number): Promise<ResultCode>; private _handleReselectRowResult; /** * Accesses the database to retrieve rows with values of parameters, filter and sort criterias that is * currently used in the DataStore. * @returns Promise object * @see {@link retrieve} * @since 0.0.0 */ reselectRows(): Promise<number>; /** * * @returns Object with the following structure: * {newRows:[], insertedRows[], updatedRows[], deletedRows[]} */ private _getChangedRows; /** * Retrieves changes made to a DataWindow or DataStore as a JSON string. This method is used primarily in distributed applications. * @returns JSON string * @since 0.0.0 */ getChanges(): string; /** * Applies changes captured with {@link getChanges} to a DataWindow or DataStore. This method is used primarily in distributed applications. * @param changes JSON string created with {@link getChanges} from which you want to apply changes. * @param conflictResolution A value indicating how conflicts should be resolved. Default is _FailOnAnyConflict!_ * @see {@link getChanges} * @since 0.0.0 */ setChanges(changes: string, conflictResolution?: "FailOnAnyConflict!" | "AllowPartialChanges!"): ResultCode; /** * Updates the database with the changes made in a DataWindow control or DataStore. * Method {@link update} can also call {@link acceptText} for the current row and column before it updates the database. * @param accept (optional) A `boolean` value specifying whether the DataWindow control or DataStore should automatically perform an AcceptText prior to performing the update. Default is _true_. * @param resetflag (optional) A `boolean` value specifying whether the DataWindow control or DataStore should automatically reset the update flags. Default is _true_. * @returns {Promise<ResultCode>} `Promise` of update result code: Success(1), Failure(-1) or Nothing(0) happennings * @since 0.0.0 * @see {@link acceptText} * @see {@link resetUpdate} * @see {@link updatesPending} * @see {@link updating} */ update(accept?: boolean, resetflag?: boolean): Promise<ResultCode>; /** * Prepare requests and call update methods to the database */ private _updateBackend; /** * Handle update response from the backend in the JSON-RPC 2.0 format * @param data Response data * @param outcome The results of the server response processing */ private _handleUpdateResponse; /** * Gets the unique row identifier of a row in a DataWindow control or DataStore object from the row number associated with that row. * The row identifier value is not the same as the row number value used in many DataWindow and DataStore function calls and * should not be used for the row number value. Instead, you should first convert the unique row identifier into a row number by calling * {@link getRowFromRowId}. * @param row A number specifying the row number for which you want the associated row identifier. * @param bufferType A value of the `BufferType` enumerated datatype. Default is `Primary!` * @returns Returns the row identifier in buffer. Returns -1 if the row identifier is not in the current buffer and -1 if an error occurs. * @see {@link getRowFromRowId} * @since 0.0.0 */ getRowIdFromRow(row: number | Object, bufferType?: BufferType): number; /** * Gets the row number of a row in a DataWindow control or DataStore object from the unique row identifier associated with that row. * @param rowID A number specifying the row identifier for which you want the associated row number. * @param bufferType A value of the `BufferType` enumerated datatype. Default is `Primary!` * @returns Returns the row number in buffer. Returns -1 if the row number is not in the current buffer * @see {@link getRowIdFromRow} * @since 0.0.0 */ getRowFromRowId(rowID: number, bufferType?: BufferType): number; /** * Reports the modification status of a row or a column within a row. The modification status determines the type of * SQL statement the Update method will generate for the row or column. * @param row A value identifying the row for which you want the status * @param column The column for which you want the status. Column can be a column number or a column name. * The column number is the number of the column as it is listed in the Column Specification. * @param bufferType A value identifying the DataWindow buffer containing the row for which you want status * @returns A value of the `ItemStatus` enumerated datatype. If column is null, getItemStatus returns the status of row. * If there is no DataWindow object assigned to the DataWindow control or DataStore, {@link getItemStatus} returns undefined. * @see {@link setItemStatus} * @since 0.0.0 */ getItemStatus(row: number, column?: number | string | null, bufferType?: BufferType): ItemStatus | undefined; /** * Changes the modification status of a row or a column within a row. The modification status determines the type of * SQL statement the Update method will generate for the row. * @param row The row location in which you want to set the status. * @param column The column location in which you want to set the status. Column can be a column number or a column * name. To set the status for the row, enter null for column. * @param bufferType A value identifying the DataWindow buffer that contains the row. * @param status A value of the `ItemStatus` enumerated datatype * @returns 1 if it succeeds and -1 if an error occurs. * @see {@link getItemStatus} * @since 0.0.0 */ setItemStatus(row: number, column: number | string | null, bufferType: BufferType, status: ItemStatus): ResultCode; /** * Gets data from the specified row and column values in the specified Buffer.You can obtain * the data that was originally retrieved and stored in the database from the original buffer, * as well as the current value in the primary, delete, or filter buffers. * @param row A value identifying the row location of the data. * @param column The column location of the data. Column can be a column number or a column name. * @param bufferType A value identifying the DataWindow buffer from which you want to get the data. * @param original A boolean indicating whether you want the original or current values for row and column: * True - Returns the original values (the values initially retrieved from the database). * False - (Default) Returns the current values. * @returns Returns the value in the specified row and column. Returns _null_ if the column value is null or * if there is no DataWindow object assigned to the DataWindow control or DataStore. * @see {@link getItemStatus} * @see {@link setItem} * @since 0.0.0 */ getItem(row: number, column: string | number, bufferType?: BufferType, original?: boolean): any | null; /** * Returns the string data in the specified row and column of the DataStore. * * @param row A value identifying the row location of the data. * @param column The column location of the data. Column can be a column number or a column name. * @param bufferType A value identifying the DataWindow buffer from which you want to get the data. * @param original A boolean indicating whether you want the original or current values for row and column: * True - Returns the original values (the values initially retrieved from the database). * False - (Default) Returns the current values. * @returns If item's value is null, returns null, else the result of converting to String data type * @see {@link getItem} * @since 0.0.0 */ getItemString(row: number, column: string | number, bufferType?: BufferType, original?: boolean): string | null; /** * Returns the numeric data in the specified row and column of the DataStore. * * @param row A value identifying the row location of the data. * @param column The column location of the data. Column can be a column number or a column name. * @param bufferType A value identifying the DataWindow buffer from which you want to get the data. * @param original A boolean indicating whether you want the original or current values for row and column: * True - Returns the original values (the values initially retrieved from the database). * False - (Default) Returns the current values. * @returns If item's value is null, returns null, else the result of converting to Number data type * @see {@link getItem} * @since 0.0.0 */ getItemNumber(row: number, column: string | number, bufferType?: BufferType, original?: boolean): number | null; /** * Returns the decimal data in the specified row and column of the DataStore. * @param row A value identifying the row location of the data. * @param column The column location of the data. Column can be a column number or a column name. * @param bufferType A value identifying the DataWindow buffer from which you want to get the data. * @param original A boolean indicating whether you want the original or current values for row and column: * True - Returns the original values (the values initially retrieved from the database). * False - (Default) Returns the current values. * @returns If item's value is null, returns null, else the result of converting to Decimal data type * @since 0.0.0 */ getItemDecimal(row: number, column: string | number, bufferType?: BufferType, original?: boolean): Decimal | null; /** * Returns the date data in the specified row and column of the DataStore. * @param row A value identifying the row location of the data. * @param column The column location of the data. Column can be a column number or a column name. * @param bufferType A value identifying the DataWindow buffer from which you want to get the data. * @param original A boolean indicating whether you want the original or current values for row and column: * True - Returns the original values (the values initially retrieved from the database). * False - (Default) Returns the current values. * @returns If item's value is null, returns null, else the result of converting to Date data type * @see {@link getItem} * @since 0.0.0 */ getItemDate(row: number, column: string | number, bufferType?: BufferType, original?: boolean): Date | null; /** * Returns the datetime data in the specified row and column of the DataStore. * @param row A value identifying the row location of the data. * @param column The column location of the data. Column can be a column number or a column name. * @param bufferType A value identifying the DataWindow buffer from which you want to get the data. * @param original A boolean indicating whether you want the original or current values for row and column: * True - Returns the original values (the values initially retrieved from the database). * False - (Default) Returns the current values. * @returns If item's value is null, returns null, else the result of converting to DateTime data type * @see {@link getItem} * @since 0.0.0 */ getItemDateTime(row: number, column: string | number, bufferType?: BufferType, original?: boolean): DateTime | null; /**