mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
create sortable table
This commit is contained in:
26
scm-ui/ui-components/src/table/TextColumn.tsx
Normal file
26
scm-ui/ui-components/src/table/TextColumn.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import React, { FC } from "react";
|
||||
import {ColumnProps} from "./types";
|
||||
|
||||
type Props = ColumnProps & {
|
||||
dataKey: string;
|
||||
};
|
||||
|
||||
const TextColumn: FC<Props> = ({ row, dataKey }) => {
|
||||
return row[dataKey];
|
||||
};
|
||||
|
||||
TextColumn.defaultProps = {
|
||||
createComparator: (props: Props) => {
|
||||
return (a: any, b: any) => {
|
||||
if (a[props.dataKey] < b[props.dataKey]) {
|
||||
return -1;
|
||||
} else if (a[props.dataKey] > b[props.dataKey]) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default TextColumn;
|
||||
Reference in New Issue
Block a user