diff --git a/src/components/column/Column.d.ts b/src/components/column/Column.d.ts index 664c8fd3b8..d582e24485 100644 --- a/src/components/column/Column.d.ts +++ b/src/components/column/Column.d.ts @@ -1,6 +1,8 @@ import * as React from 'react'; -type ColumnBodyType = React.ReactNode | ((data: any, props: ColumnProps, ...parameters: any) => React.ReactNode); +type ColumnBodyType = React.ReactNode | ((data: any, options: ColumnBodyOptions) => React.ReactNode); + +type ColumnEditorType = React.ReactNode | ((options: ColumnEditorOptions) => React.ReactNode); type ColumnFilterMatchModeType = 'startsWith' | 'contains' | 'endsWith' | 'equals' | 'notEquals' | 'in' | 'lt' | 'lte' | 'gt' | 'gte' | 'custom'; @@ -26,6 +28,26 @@ type ColumnFilterElementType = React.ReactNode | ((options: ColumnFilterElementT type ColumnFilterModelType = ColumnFilterMetaData | ColumnFilterMetaDataWithConstraint; +interface ColumnBodyOptions { + column: Column; + field: string; + rowIndex: number; + frozenRow?: boolean; + props: any; +} + +interface ColumnEditorOptions { + node?: any; + rowData: any; + value: any; + column: Column; + field: string; + rowIndex: number; + frozenRow?: boolean; + props: any; + editorCallback?(val: any): void; +} + interface ColumnFilterModelOptions { [key: string]: ColumnFilterModelType; } @@ -183,7 +205,7 @@ export interface ColumnProps { onCellEditCancel?(e: ColumnEventParams): void; sortFunction?(e: ColumnSortParams): void; filterFunction?(value: any, filter: any, filterLocale: string, params: ColumnFilterParams): void; - editor?(props: ColumnProps): React.ReactNode; + editor?: ColumnEditorType; cellEditValidator?(e: ColumnEventParams): boolean; onBeforeCellEditHide?(e: ColumnEventParams): void; onBeforeCellEditShow?(e: ColumnEventParams): void; diff --git a/src/components/datatable/BodyCell.js b/src/components/datatable/BodyCell.js index d86cb36df0..ee4020381c 100644 --- a/src/components/datatable/BodyCell.js +++ b/src/components/datatable/BodyCell.js @@ -392,15 +392,15 @@ export class BodyCell extends Component { } onRowEditInit(event) { - this.props.onRowEditInit({ originalEvent: event, data: this.props.rowData, newData: this.getEditingRowData(), field: this.field, index: this.props.rowIndex, editorCallback: this.editorCallback }); + this.props.onRowEditInit({ originalEvent: event, data: this.props.rowData, newData: this.getEditingRowData(), field: this.field, index: this.props.rowIndex }); } onRowEditSave(event) { - this.props.onRowEditSave({ originalEvent: event, data: this.props.rowData, newData: this.getEditingRowData(), field: this.field, index: this.props.rowIndex, editorCallback: this.editorCallback }); + this.props.onRowEditSave({ originalEvent: event, data: this.props.rowData, newData: this.getEditingRowData(), field: this.field, index: this.props.rowIndex }); } onRowEditCancel(event) { - this.props.onRowEditCancel({ originalEvent: event, data: this.props.rowData, newData: this.getEditingRowData(), field: this.field, index: this.props.rowIndex, editorCallback: this.editorCallback }); + this.props.onRowEditCancel({ originalEvent: event, data: this.props.rowData, newData: this.getEditingRowData(), field: this.field, index: this.props.rowIndex }); } bindDocumentEditListener() { @@ -517,10 +517,10 @@ export class BodyCell extends Component { const title = this.props.responsiveLayout === 'stack' && {ObjectUtils.getJSXElement(header, { props: this.props })}; if (body && !this.state.editing) { - content = body ? ObjectUtils.getJSXElement(body, this.props.rowData, { column: this.props.column, field: this.field, rowIndex: this.props.rowIndex, frozenRow: this.props.frozenRow }) : value; + content = body ? ObjectUtils.getJSXElement(body, this.props.rowData, { column: this.props.column, field: this.field, rowIndex: this.props.rowIndex, frozenRow: this.props.frozenRow, props: this.props.tableProps }) : value; } else if (editor && this.state.editing) { - content = ObjectUtils.getJSXElement(editor, { rowData: this.state.editingRowData, value: this.resolveFieldData(this.state.editingRowData), column: this.props.column, field: this.field, rowIndex: this.props.rowIndex, frozenRow: this.props.frozenRow, editorCallback: this.editorCallback }); + content = ObjectUtils.getJSXElement(editor, { rowData: this.state.editingRowData, value: this.resolveFieldData(this.state.editingRowData), column: this.props.column, field: this.field, rowIndex: this.props.rowIndex, frozenRow: this.props.frozenRow, props: this.props.tableProps, editorCallback: this.editorCallback }); } else if (selectionMode) { const showSelection = this.props.showSelectionElement ? this.props.showSelectionElement(this.props.rowData, { index: this.props.rowIndex, props: this.props.tableProps }) : true; diff --git a/src/components/datatable/DataTable.d.ts b/src/components/datatable/DataTable.d.ts index eccdb46b99..05ca748684 100644 --- a/src/components/datatable/DataTable.d.ts +++ b/src/components/datatable/DataTable.d.ts @@ -43,6 +43,8 @@ type DataTableFilterDisplayType = 'menu' | 'row'; type DataTableSizeType = 'small' | 'normal' | 'large'; +type DataTableScrollDirectionType = 'vertical' | 'horizontal' | 'both'; + interface DataTableHeaderTemplateOptions { props: DataTableProps; } @@ -156,7 +158,6 @@ interface DataTableRowEditCompleteParams extends DataTableRowEventParams { newData: any; field: string; index: number; - editorCallback(value: any): void; } interface DataTableSelectParams { @@ -265,6 +266,7 @@ export interface DataTableProps { filterLocale?: string; scrollable?: boolean; scrollHeight?: string; + scrollDirection?: DataTableScrollDirectionType; virtualScrollerOptions?: VirtualScrollerProps; frozenWidth?: string; frozenValue?: any[]; diff --git a/src/components/datatable/DataTable.js b/src/components/datatable/DataTable.js index 24b989583b..169f3a7366 100644 --- a/src/components/datatable/DataTable.js +++ b/src/components/datatable/DataTable.js @@ -66,6 +66,7 @@ export class DataTable extends Component { filterLocale: undefined, scrollable: false, scrollHeight: null, + scrollDirection: 'vertical', virtualScrollerOptions: null, frozenWidth: null, frozenValue: null, @@ -188,6 +189,7 @@ export class DataTable extends Component { filterLocale: PropTypes.string, scrollable: PropTypes.bool, scrollHeight: PropTypes.string, + scrollDirection: PropTypes.string, virtualScrollerOptions: PropTypes.object, frozenWidth: PropTypes.string, frozenValue: PropTypes.array,