Skip to content

Commit

Permalink
Fix onClick event for column button (#25395)
Browse files Browse the repository at this point in the history
  • Loading branch information
dxvladislavvolkov authored Sep 21, 2023
1 parent c721c32 commit 9877326
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@angular/core';

import { dxButtonOptions } from 'devextreme/ui/button';
import { ColumnButtonClickEvent } from 'devextreme/ui/data_grid';

@Component({
template: ''
Expand Down Expand Up @@ -60,10 +61,10 @@ export abstract class DxiTextEditorButton extends CollectionNestedOption {
this._setOption('icon', value);
}

get onClick(): Function {
get onClick(): ((e: ColumnButtonClickEvent) => void) {
return this._getOption('onClick');
}
set onClick(value: Function) {
set onClick(value: ((e: ColumnButtonClickEvent) => void)) {
this._setOption('onClick', value);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/devextreme-react/src/data-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import * as PropTypes from "prop-types";
import { Component as BaseComponent, IHtmlOptions } from "./core/component";
import NestedOption from "./core/nested-option";

import type { dxDataGridColumn, AdaptiveDetailRowPreparingEvent, CellClickEvent, CellDblClickEvent, CellPreparedEvent, ContentReadyEvent, ContextMenuPreparingEvent, DataErrorOccurredEvent, DisposingEvent, EditCanceledEvent, EditCancelingEvent, EditingStartEvent, EditorPreparedEvent, EditorPreparingEvent, ExportingEvent, FocusedCellChangingEvent, FocusedRowChangingEvent, InitializedEvent, InitNewRowEvent, KeyDownEvent, RowClickEvent, RowCollapsedEvent, RowCollapsingEvent, RowDblClickEvent, RowExpandedEvent, RowExpandingEvent, RowInsertedEvent, RowInsertingEvent, RowPreparedEvent, RowRemovedEvent, RowRemovingEvent, RowUpdatedEvent, RowUpdatingEvent, RowValidatingEvent, SavedEvent, SavingEvent, ToolbarPreparingEvent, dxDataGridRowObject, dxDataGridColumnButton, dxDataGridToolbarItem } from "devextreme/ui/data_grid";
import type { dxDataGridColumn, AdaptiveDetailRowPreparingEvent, CellClickEvent, CellDblClickEvent, CellPreparedEvent, ContentReadyEvent, ContextMenuPreparingEvent, DataErrorOccurredEvent, DisposingEvent, EditCanceledEvent, EditCancelingEvent, EditingStartEvent, EditorPreparedEvent, EditorPreparingEvent, ExportingEvent, FocusedCellChangingEvent, FocusedRowChangingEvent, InitializedEvent, InitNewRowEvent, KeyDownEvent, RowClickEvent, RowCollapsedEvent, RowCollapsingEvent, RowDblClickEvent, RowExpandedEvent, RowExpandingEvent, RowInsertedEvent, RowInsertingEvent, RowPreparedEvent, RowRemovedEvent, RowRemovingEvent, RowUpdatedEvent, RowUpdatingEvent, RowValidatingEvent, SavedEvent, SavingEvent, ToolbarPreparingEvent, dxDataGridRowObject, ColumnButtonClickEvent, dxDataGridColumnButton, dxDataGridToolbarItem } from "devextreme/ui/data_grid";
import type { DataChange, ColumnHeaderFilterSearchConfig, ColumnChooserSearchConfig, ColumnChooserSelectionConfig, HeaderFilterSearchConfig, GridBase } from "devextreme/common/grids";
import type { ContentReadyEvent as FilterBuilderContentReadyEvent, DisposingEvent as FilterBuilderDisposingEvent, EditorPreparedEvent as FilterBuilderEditorPreparedEvent, EditorPreparingEvent as FilterBuilderEditorPreparingEvent, InitializedEvent as FilterBuilderInitializedEvent, dxFilterBuilderField, dxFilterBuilderCustomOperation, OptionChangedEvent, ValueChangedEvent } from "devextreme/ui/filter_builder";
import type { ContentReadyEvent as FormContentReadyEvent, DisposingEvent as FormDisposingEvent, InitializedEvent as FormInitializedEvent, dxFormSimpleItem, dxFormOptions, OptionChangedEvent as FormOptionChangedEvent, dxFormGroupItem, dxFormTabbedItem, dxFormEmptyItem, dxFormButtonItem, EditorEnterKeyEvent, FieldDataChangedEvent } from "devextreme/ui/form";
import type { AnimationConfig, AnimationState } from "devextreme/animation/fx";
import type { event, EventInfo } from "devextreme/events/index";
import type { template } from "devextreme/core/templates/template";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { PositionConfig } from "devextreme/animation/position";
import type { dxPopupOptions, dxPopupToolbarItem } from "devextreme/ui/popup";
import type { event, EventInfo } from "devextreme/events/index";
import type { Component } from "devextreme/core/component";
import type { CollectionWidgetItem } from "devextreme/ui/collection/ui.collection_widget.base";

Expand Down Expand Up @@ -403,7 +403,7 @@ type IButtonProps = React.PropsWithChildren<{
hint?: string;
icon?: string;
name?: "cancel" | "delete" | "edit" | "save" | "undelete";
onClick?: ((e: { column: dxDataGridColumn, component: dxDataGrid, element: any, event: event, model: Record<string, any>, row: dxDataGridRowObject }) => void);
onClick?: ((e: ColumnButtonClickEvent) => void);
template?: ((cellElement: any, cellInfo: { column: dxDataGridColumn, columnIndex: number, component: dxDataGrid, data: Record<string, any>, key: any, row: dxDataGridRowObject, rowIndex: number, rowType: string }) => string | any) | template;
text?: string;
visible?: boolean | ((options: { column: dxDataGridColumn, component: dxDataGrid, row: dxDataGridRowObject }) => boolean);
Expand Down
22 changes: 15 additions & 7 deletions packages/devextreme/js/ui/data_grid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,22 @@ export type RowDraggingRemoveEvent<TRowData = any, TKey = any> = ReducedNativeEv
/** @public */
export type RowDraggingReorderEvent<TRowData = any, TKey = any> = ReducedNativeEventInfo<dxDataGrid<TRowData, TKey>> & RowDraggingEventInfo<TRowData> & DragReorderInfo;

/** @public */
/**
* @docid _ui_data_grid_ColumnButtonClickEvent
* @public
* @type object
* @inherits NativeEventInfo
*/
export type ColumnButtonClickEvent<TRowData = any, TKey = any> = NativeEventInfo<dxDataGrid<TRowData, TKey>, PointerEvent | MouseEvent> & {
/**
* @docid _ui_data_grid_ColumnButtonClickEvent.row
* @type dxDataGridRowObject
*/
row?: Row<TRowData, TKey>;
/**
* @docid _ui_data_grid_ColumnButtonClickEvent.column
* @type dxDataGridColumn
*/
column?: Column<TRowData, TKey>;
};

Expand Down Expand Up @@ -2303,12 +2316,7 @@ export interface dxDataGridColumnButton<TRowData = any, TKey = any> extends Colu
name?: DataGridPredefinedColumnButton | string;
/**
* @docid dxDataGridColumnButton.onClick
* @type_function_param1 e:object
* @type_function_param1_field component:dxDataGrid
* @type_function_param1_field model:object
* @type_function_param1_field event:event
* @type_function_param1_field row:dxDataGridRowObject
* @type_function_param1_field column:dxDataGridColumn
* @type_function_param1 e:{ui/data_grid:ColumnButtonClickEvent}
* @public
*/
onClick?: ((e: ColumnButtonClickEvent<TRowData, TKey>) => void);
Expand Down
9 changes: 9 additions & 0 deletions packages/devextreme/ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9985,14 +9985,23 @@ declare module DevExpress.ui {
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export type ColumnButtonBase = DevExpress.common.grids.ColumnButtonBase;
/**
* [descr:_ui_data_grid_ColumnButtonClickEvent]
*/
export type ColumnButtonClickEvent<
TRowData = any,
TKey = any
> = DevExpress.events.NativeEventInfo<
dxDataGrid<TRowData, TKey>,
PointerEvent | MouseEvent
> & {
/**
* [descr:_ui_data_grid_ColumnButtonClickEvent.row]
*/
row?: Row<TRowData, TKey>;
/**
* [descr:_ui_data_grid_ColumnButtonClickEvent.column]
*/
column?: Column<TRowData, TKey>;
};
export type ColumnButtonTemplateData<TRowData = any, TKey = any> = {
Expand Down

0 comments on commit 9877326

Please sign in to comment.