UNPKG

@syncfusion/ej2-grids

Version:

Feature-rich JavaScript datagrid (datatable) control with built-in support for editing, filtering, grouping, paging, sorting, and exporting to Excel.

278 lines (277 loc) 8.64 kB
import { L10n } from '@syncfusion/ej2-base'; import { IGrid, IAction, NotifyArgs, IEdit } from '../base/interface'; import { EditRender } from '../renderer/edit-renderer'; import { ServiceLocator } from '../services/service-locator'; import { Column } from '../models/column'; import { Dialog } from '@syncfusion/ej2-popups'; import { FormValidator } from '@syncfusion/ej2-inputs'; /** * The `Edit` module is used to handle editing actions. */ export declare class Edit implements IAction { protected renderer: EditRender; /** @hidden */ editModule: IEdit; /** @hidden */ formObj: FormValidator; /** @hidden */ virtualFormObj: FormValidator; /** @hidden */ isShowAddedRowValidate: boolean; private static editCellType; private editType; protected parent: IGrid; protected serviceLocator: ServiceLocator; protected l10n: L10n; dialogObj: Dialog; private fieldname; private data; alertDObj: Dialog; private actionBeginFunction; private actionCompleteFunction; private onDataBoundFunction; private preventObj; private eventDetails; isLastRow?: boolean; deleteRowUid: string; editCellDialogClose: boolean; /** * Constructor for the Grid editing module * * @param {IGrid} parent - specifies the IGrid * @param {ServiceLocator} serviceLocator - specifies the servicelocator * @hidden */ constructor(parent?: IGrid, serviceLocator?: ServiceLocator); private updateColTypeObj; /** * For internal use only - Get the module name. * * @returns {string} returns the module name * @private */ protected getModuleName(): string; /** * @param {NotifyArgs} e - specifies the notifyargs * @returns {void} * @hidden */ onPropertyChanged(e: NotifyArgs): void; private updateEditObj; private initialEnd; /** * Edits any bound record in the Grid by TR element. * * @param {HTMLTableRowElement} tr - Defines the table row to be edited. * @returns {void} */ startEdit(tr?: HTMLTableRowElement): void; /** * @param {Element} tr - specifies the tr element * @param {object} args - specifies the object * @param {Element} args.row -specfifes the row * @param {string} args.requestType - specifies the request type * @returns {void} * @hidden */ checkLastRow(tr: Element, args?: { row?: Element; requestType?: string; }): void; /** * Cancels edited state. * * @returns {void} */ closeEdit(): void; protected refreshToolbar(): void; /** * To adds a new row at the top with the given data. When data is not passed, it will add empty rows. * > `editSettings.allowEditing` should be true. * * @param {Object} data - Defines the new add record data. * @param {number} index - Defines the row index to be added * @returns {void} */ addRecord(data?: Object, index?: number): void; /** * Deletes a record with the given options. If fieldname and data are not given, the Grid will delete the selected record. * > `editSettings.allowDeleting` should be true. * * @param {string} fieldname - Defines the primary key field name of the column. * @param {Object} data - Defines the JSON data record to be deleted. * @returns {void} */ deleteRecord(fieldname?: string, data?: Object): void; /** * Deletes a visible row by TR element. * * @param {HTMLTableRowElement} tr - Defines the table row element. * @returns {void} */ deleteRow(tr: HTMLTableRowElement): void; /** * If Grid is in editable state, you can save a record by invoking endEdit. * * @returns {void} */ endEdit(): void; /** * To update the specified cell by given value without changing into edited state. * * @param {number} rowIndex Defines the row index. * @param {string} field Defines the column field. * @param {string | number | boolean | Date} value - Defines the value to be changed. * @returns {void} */ updateCell(rowIndex: number, field: string, value: string | number | boolean | Date): void; /** * To update the specified row by given values without changing into edited state. * * @param {number} index Defines the row index. * @param {Object} data Defines the data object to be updated. * @returns {void} */ updateRow(index: number, data: Object): void; /** * Resets added, edited, and deleted records in the batch mode. * * @returns {void} */ batchCancel(): void; /** * Bulk saves added, edited, and deleted records in the batch mode. * * @returns {void} */ batchSave(): void; /** * Changes a particular cell into edited state based on the row index and field name provided in the `batch` mode. * * @param {number} index - Defines row index to edit a particular cell. * @param {string} field - Defines the field name of the column to perform batch edit. * @returns {void} */ editCell(index: number, field: string): void; /** * Checks the status of validation at the time of editing. If validation is passed, it returns true. * * @returns {boolean} returns whether the form is validated */ editFormValidate(): boolean; /** * Gets the added, edited,and deleted data before bulk save to the DataSource in batch mode. * * @returns {Object} returns the Object */ getBatchChanges(): Object; /** * Gets the current value of the edited component. * * @returns {Object} returns the Object */ getCurrentEditCellData(): Object; /** * Saves the cell that is currently edited. It does not save the value to the DataSource. * * @returns {void} */ saveCell(): void; private endEditing; private showDialog; getValueFromType(col: Column, value: string | Date | boolean): number | string | Date | boolean; private destroyToolTip; private createConfirmDlg; private createAlertDlg; private alertClick; private dlgWidget; private dlgCancel; private dlgOk; private destroyEditComponents; /** * @returns {void} * @hidden */ addEventListener(): void; /** * @returns {void} * @hidden */ removeEventListener(): void; private actionComplete; /** * @param {Element} form - specifies the element * @param {Object} editedData - specifies the edited data * @returns {Object} returns the object * @hidden */ getCurrentEditedData(form: Element, editedData: Object): Object; private getValue; /** * @param {NotifyArgs} e - specifies the NotifyArgs * @returns {void} * @hidden */ onActionBegin(e: NotifyArgs): void; /** * @param {Column[]} cols - specfies the column * @returns {void} * @hidden */ destroyWidgets(cols?: Column[]): void; /** * @returns {void} * @hidden */ destroyForm(): void; /** * To destroy the editing. * * @returns {void} * @hidden */ destroy(): void; private keyPressHandler; private curretRowFocus; private preventBatch; private executeAction; /** * @param {Column[]} cols - specifies the column * @param {Object} newRule - specifies the new rule object * @returns {void} * @hidden */ applyFormValidation(cols?: Column[], newRule?: Object): void; /** * @param {HTMLFormElement} form - Defined Form element * @param {Object} rules - Defines form rules * @returns {FormValidator} Returns formvalidator instance * @hidden */ createFormObj(form: HTMLFormElement, rules: Object): FormValidator; private valErrorPlacement; private getElemTable; resetElemPosition(elem: HTMLElement, args: { status: string; inputName: string; element: HTMLElement; message: string; }): void; private validationComplete; private setScrollTop; private setBottomStyles; private setPositionStyles; private createTooltip; /** * @param {Column} col - specfies the column * @returns {boolean} returns the whether column is grouped * @hidden */ checkColumnIsGrouped(col: Column): boolean; /** * @param {object} editors -specfies the editors * @returns {void} * @hidden */ static AddEditors(editors: object): void; }