You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/ui/docs/components/table.md
+26-23Lines changed: 26 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -427,6 +427,32 @@ t = ui.table(
427
427
)
428
428
```
429
429
430
+
### Always fetching some columns
431
+
432
+
Deephaven only fetches data for visible rows and columns within a window around the viewport (typically the viewport plus 1 page in all directions). This reduces the amount of data transferred between the server and client and allows displaying tables with billions of rows. Sometimes you may need to always fetch columns, such as a key column for a row press event. You can use the `always_fetch_columns` prop to specify columns that should always be fetched regardless of their visibility.
433
+
434
+
The `always_fetch_columns` prop takes a single column name, a list of column names, or a boolean to always fetch all columns. The data for these columns is included in row event data (e.g. `on_row_press`) and context menu callbacks.
435
+
436
+
> [!TIP]
437
+
> **Best Practice for Event Callbacks**: When using event callbacks (such as `on_row_press`, `on_cell_press`, or `on_selection_change`), it's recommended to include any column you will be using in the callback in `always_fetch_columns`. This prevents potentially undefined columns if users hide those columns or scroll far right where the original columns are no longer in the viewport.
438
+
439
+
> [!WARNING]
440
+
> Setting `always_fetch_columns` to `True` will fetch all columns and can be slow for tables with many columns.
441
+
442
+
This example shows how to use `always_fetch_columns` to always fetch the `Sym` column for a row press event. Without the `always_fetch_columns` prop, the press callback will fail because the `Sym` column is not fetched when hidden.
443
+
444
+
```python
445
+
from deephaven import ui
446
+
import deephaven.plot.express as dx
447
+
448
+
t = ui.table(
449
+
dx.data.stocks(),
450
+
hidden_columns=["Sym"],
451
+
on_row_press=lambdad: print(d["Sym"]),
452
+
always_fetch_columns="Sym",
453
+
)
454
+
```
455
+
430
456
### Selection Event
431
457
432
458
The `on_selection_change` event is triggered when the user selects or deselects a row. The event data will contain all selected rows within the viewport as a list of dictionaries keyed by column name. There are a few caveats to the selection event.
@@ -610,29 +636,6 @@ t = ui.table(
610
636
611
637

612
638
613
-
## Always fetching some columns
614
-
615
-
Deephaven only fetches data for visible rows and columns within a window around the viewport (typically the viewport plus 1 page in all directions). This reduces the amount of data transferred between the server and client and allows displaying tables with billions of rows. Sometimes you may need to always fetch columns, such as a key column for a row press event. You can use the `always_fetch_columns` prop to specify columns that should always be fetched regardless of their visibility.
616
-
617
-
The `always_fetch_columns` prop takes a single column name, a list of column names, or a boolean to always fetch all columns. The data for these columns is included in row event data (e.g. `on_row_press`) and context menu callbacks.
618
-
619
-
> [!WARNING]
620
-
> Setting `always_fetch_columns` to `True` will fetch all columns and can be slow for tables with many columns.
621
-
622
-
This example shows how to use `always_fetch_columns` to always fetch the `Sym` column for a row press event. Without the `always_fetch_columns` prop, the press callback will fail because the `Sym` column is not fetched when hidden.
623
-
624
-
```python
625
-
from deephaven import ui
626
-
import deephaven.plot.express as dx
627
-
628
-
t = ui.table(
629
-
dx.data.stocks(),
630
-
hidden_columns=["Sym"],
631
-
on_row_press=lambdad: print(d["Sym"]),
632
-
always_fetch_columns="Sym",
633
-
)
634
-
```
635
-
636
639
## Quick filters
637
640
638
641
Quick filters are an easy way to filter the table while also showing the user what filters are currently applied. These filters are applied on the server via request from the client, so users may change the filters without affecting other users. Unlike a `where` statement to filter a table on the server, quick filters can be easily changed by the user.
0 commit comments