Skip to content

Commit

Permalink
add README + default property to OrderBy
Browse files Browse the repository at this point in the history
  • Loading branch information
severo committed Jan 20, 2025
1 parent 4544727 commit 0392bf3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ interface TableProps {
focus?: boolean // focus table on mount? (default true)
onDoubleClickCell?: (col: number, row: number) => void // double-click handler
onError?: (error: Error) => void // error handler
orderBy?: OrderBy; // order by column (if defined, the component order is controlled by the parent)
onOrderByChange?: (orderBy: OrderBy) => void; // orderBy change handler
selection?: Selection; // selection state (if defined, the component selection is controlled by the parent)
onSelectionChange?: (selection: Selection) => void; // selection change handler
}
```

Expand All @@ -95,6 +99,27 @@ interface DataFrame {
}
```

OrderBy is defined as:

```typescript
interface OrderBy {
column: string; // column name
direction?: "ascending"; // sort direction - only ascending is supported
}
```

Selection is defined as:

```typescript
interface Selection {
ranges: Array<{
start: number; // inclusive lower limit, positive integer
end: number; // exclusive upper limit, positive integer, strictly greater than start (no zero-length ranges).
}>; // the rows selection is an array of row index ranges (0-based). The values are indexes of the virtual table (sorted rows), and thus depend on the order.
anchor?: number; // anchor row used as a reference for shift+click selection. It's a virtual table index (sorted), and thus depends on the order.
}
```

## Sortable DataFrame

If your data source supports sorting, set the sortable property to true in your DataFrame object. When sorting is enabled, the rows function will receive an additional orderBy parameter, which represents the column name to sort by.
Expand Down
2 changes: 1 addition & 1 deletion src/sort.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface OrderBy {
column?: string // column name to sort by. If undefined, the table is unsorted.
/// TODO(SL): ascending / descending
direction?: 'ascending' // sort direction. Default: 'ascending'
}

0 comments on commit 0392bf3

Please sign in to comment.