Skip to content

Commit

Permalink
Fixed #3352 and #3353
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Sep 22, 2022
1 parent 220d606 commit 52d5c85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions components/lib/column/column.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,16 @@ interface ColumnEventParams {
columnProps: ColumnProps;
}

interface ColumnSortParams {
rowData: any;
interface ColumnSortMetaData {
field: string;
order: ColumnSortOrderType;
}

interface ColumnSortParams extends ColumnSortMetaData {
data: any;
multiSortMeta?: ColumnSortMetaData[];
}

interface ColumnFilterMetaData {
value: any;
matchMode: ColumnFilterMatchModeType;
Expand Down
8 changes: 4 additions & 4 deletions components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ export const DataTable = React.forwardRef((props, ref) => {

columnSortable.current = column.props.sortable;
columnSortFunction.current = column.props.sortFunction;
columnField.current = column.props.sortField;
columnField.current = sortField;

if (props.sortMode === 'multiple') {
let metaKey = event.metaKey || event.ctrlKey;
Expand Down Expand Up @@ -911,7 +911,7 @@ export const DataTable = React.forwardRef((props, ref) => {
let value = [...data];

if (columnSortable.current && columnSortFunction.current) {
value = columnSortFunction.current({ rowData: value, field: field, order: order });
value = columnSortFunction.current({ data, field, order });
} else {
value.sort((data1, data2) => {
const value1 = ObjectUtils.resolveFieldData(data1, field);
Expand Down Expand Up @@ -944,9 +944,9 @@ export const DataTable = React.forwardRef((props, ref) => {
if (columnSortable.current && columnSortFunction.current) {
const meta = multiSortMeta.find((meta) => meta.field === columnField.current);
const field = columnField.current;
const order = meta ? meta.order : defaultSortOrder;
const order = meta ? meta.order : props.defaultSortOrder;

value = columnSortFunction.current({ rowData: value, field: field, order: order });
value = columnSortFunction.current({ data, field, order, multiSortMeta });
} else {
value.sort((data1, data2) => {
return multisortField(data1, data2, multiSortMeta, 0);
Expand Down
2 changes: 1 addition & 1 deletion components/lib/treetable/TreeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const TreeTable = React.forwardRef((props, ref) => {

if (columnSortable.current && columnSortable.current === 'custom' && columnSortFunction.current) {
value = columnSortFunction.current({
rowData: value,
data,
field: getSortField(),
order: getSortOrder()
});
Expand Down

0 comments on commit 52d5c85

Please sign in to comment.