import * as React from 'react'; import { MmuiDefaultTable, MmuiDefaultTableProps, MmuiDefaultTableState, } from './defaultTable'; export interface MmuiDefaultSortedTableProps extends MmuiDefaultTableProps { updateTransform: (t) => void; } export interface MmuiDefaultSortedTableState extends MmuiDefaultTableState { order?: any; } export class MmuiDefaultTableSorted< P extends MmuiDefaultSortedTableProps, S extends MmuiDefaultSortedTableState > extends MmuiDefaultTable
{
constructor(props) {
super(props);
const order = {
column: undefined,
direction: undefined,
};
// @ts-ignore
this.state.order = order;
this.tableClassNameList.push('mmui-table-sortable');
}
handleSortOrderChange = (evt, col) => {
evt.preventDefault();
let orderDirection;
if (this.state.order.column === col) {
orderDirection =
this.state.order.direction === 'ASC' ? 'DESC' : 'ASC';
} else {
orderDirection = 'ASC';
}
this.setState({
order: {
column: col,
direction: orderDirection,
},
});
this.props.updateTransform((t) => ({
...t,
order: {
column: col,
method: orderDirection,
},
}));
};
getOrderDirection(col) {
if (col !== this.state.order.column) return null;
let sortSymbol;
if (this.state.order.direction == 'ASC') {
sortSymbol = ;
} else {
sortSymbol = ;
}
return sortSymbol;
}
getColumnHeaderRender(colKey, index) {
const records = this.props.records,
classList: Array
);
}
}