Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a sort button to column header #18561

Merged
merged 15 commits into from
Mar 10, 2025
Binary file removed src/reactviews/media/sort-asc.gif
Binary file not shown.
Binary file removed src/reactviews/media/sort-asc.png
Binary file not shown.
Binary file removed src/reactviews/media/sort-desc.gif
Binary file not shown.
Binary file removed src/reactviews/media/sort-desc.png
Binary file not shown.
3 changes: 3 additions & 0 deletions src/reactviews/media/sort.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 2 additions & 7 deletions src/reactviews/media/sort_asc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 2 additions & 7 deletions src/reactviews/media/sort_asc_inverse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 2 additions & 7 deletions src/reactviews/media/sort_desc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 2 additions & 7 deletions src/reactviews/media/sort_desc_inverse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/reactviews/media/sort_inverse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/reactviews/media/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,33 @@
flex: 0 0 auto;
}

.slick-header-sort-button,
.slick-header-sortdesc-button,
.slick-header-sortasc-button {
background-position: center center;
background-repeat: no-repeat;
cursor: pointer;
display: inline-block;
width: 16px;
flex: 0 0 auto;
margin-right: 2px;
background-color: transparent;
border: 0;
padding: 0;
}

.slick-header-sort-button {
background-image: url("sort_inverse.svg");
}

.slick-header-sortdesc-button {
background-image: url("sort_desc_inverse.svg");
}

.slick-header-sortasc-button {
background-image: url("sort_asc_inverse.svg");
}

.slick-header-menubutton {
background-position: center center;
background-repeat: no-repeat;
Expand Down
4 changes: 4 additions & 0 deletions src/reactviews/pages/QueryResult/table/asyncDataView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ export class AsyncDataProvider<T extends Slick.SlickData>
throw new Error("Method not implemented.");
}

resetSort(): void {
throw new Error("Method not implemented.");
}

public getLength(): number {
return this.dataRows.getLength();
}
Expand Down
5 changes: 5 additions & 0 deletions src/reactviews/pages/QueryResult/table/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export interface IDisposableDataProvider<T extends Slick.SlickData>
*/
sort(args: Slick.OnSortEventArgs<T>): Promise<void>;

/**
* Resets the sort
*/
resetSort(): void;

/**
* Event fired when the filters changed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export class HybridDataProvider<T extends Slick.SlickData>
void this.provider.sort(options);
}

public async resetSort() {
void this.provider.resetSort();
}

private get thresholdReached(): boolean {
return (
this._options.inMemoryDataCountThreshold !== undefined &&
Expand Down
6 changes: 6 additions & 0 deletions src/reactviews/pages/QueryResult/table/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { IDisposableDataProvider } from "./dataProvider";
import { SortDirection } from "./plugins/headerFilter.plugin";

export interface ITableMouseEvent {
anchor: HTMLElement | { x: number; y: number };
Expand Down Expand Up @@ -80,6 +81,11 @@ export interface FilterableColumn<T extends Slick.SlickData>
sorted?: SortProperties;
}

export interface ColumnSortState<T extends Slick.SlickData> {
column: Slick.Column<T>;
sortDirection: SortDirection;
}

export interface ITableKeyboardEvent {
cell?: { row: number; cell: number };
event: KeyboardEvent;
Expand Down
Loading
Loading