Skip to content

Commit

Permalink
Add enableSorting prop to EuiBasicTable for default sorting of table.
Browse files Browse the repository at this point in the history
Fixes: #1866
  • Loading branch information
Anupam-dagar committed Feb 23, 2020
1 parent 070acd1 commit fac4dad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/basic_table/basic_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ interface BasicTableProps<T> extends Omit<EuiTableProps, 'onChange'> {
rowProps?: object | RowPropsCallback<T>;
selection?: EuiTableSelectionType<T>;
sorting?: EuiTableSortingType<T>;
enableSorting?: boolean;
}

type BasicTableWithPaginationProps<T> = Omit<
Expand Down Expand Up @@ -444,6 +445,7 @@ export class EuiBasicTable<T = any> extends Component<
tableCaption,
rowHeader,
tableLayout,
enableSorting,
...rest
} = this.props;

Expand Down Expand Up @@ -633,6 +635,10 @@ export class EuiBasicTable<T = any> extends Component<
}

columns.forEach((column: EuiBasicTableColumn<T>, index: number) => {
if (this.props.enableSorting) {
(column as EuiTableFieldDataColumnType<T>).sortable = true;
}

const {
field,
width,
Expand Down

0 comments on commit fac4dad

Please sign in to comment.