Skip to content

Commit

Permalink
Fix #3019: Column sortFunction add rowData
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jul 4, 2022
1 parent a8a50f0 commit 6ef3421
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions components/lib/column/Column.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ interface ColumnEventParams {
}

interface ColumnSortParams {
rowData: any;
field: string;
order: ColumnSortOrderType;
}
Expand Down
6 changes: 3 additions & 3 deletions components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,14 @@ export const DataTable = React.forwardRef((props, ref) => {
let value = [...data];

if (columnSortable.current && columnSortFunction.current) {
value = columnSortFunction.current({ field, order });
value = columnSortFunction.current({ value, field, order });
}
else {
value.sort((data1, data2) => {
const value1 = ObjectUtils.resolveFieldData(data1, field);
const value2 = ObjectUtils.resolveFieldData(data2, field);

return compareValuesOnSort(value1, value2, order);;
return compareValuesOnSort(value1, value2, order);
});
}

Expand Down Expand Up @@ -933,7 +933,7 @@ export const DataTable = React.forwardRef((props, ref) => {
const field = columnField.current;
const order = meta ? meta.order : defaultSortOrder;

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

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

0 comments on commit 6ef3421

Please sign in to comment.