Skip to content

Commit

Permalink
Close #1118. Update data frame renderer to work properly with fill/fi…
Browse files Browse the repository at this point in the history
…llable
  • Loading branch information
cpsievert committed Feb 14, 2024
1 parent fbc8269 commit 3074eee
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
9 changes: 7 additions & 2 deletions js/dataframe/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ interface ShinyDataGridProps<TIndex> {
const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = (props) => {
const { id, data, bgcolor } = props;
const { columns, type_hints, data: rowData } = data;
const { width, height, filters: withFilters } = data.options;
const { width, height, fill, filters: withFilters } = data.options;

const containerRef = useRef<HTMLDivElement>(null);
const theadRef = useRef<HTMLTableSectionElement>(null);
Expand Down Expand Up @@ -227,10 +227,15 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = (props) => {

const measureEl = useVirtualizerMeasureWorkaround(rowVirtualizer);

let className = `shiny-data-grid ${containerClass} ${scrollingClass}`;
if (fill) {
className += " html-fill-item";
}

return (
<>
<div
className={`shiny-data-grid ${containerClass} ${scrollingClass}`}
className={className}
ref={containerRef}
style={{ width, maxHeight: height, overflow: "auto" }}
>
Expand Down
1 change: 1 addition & 0 deletions js/dataframe/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

.shiny-data-grid {
max-width: 100%;
height: 500px;

> table {
border-collapse: separate;
Expand Down
1 change: 1 addition & 0 deletions js/dataframe/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface DataGridOptions {
filters?: boolean;
width?: string;
height?: string;
fill?: boolean;
}

export interface PandasData<TIndex> {
Expand Down
3 changes: 2 additions & 1 deletion shiny/render/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
data: object,
*,
width: str | float | None = "fit-content",
height: Union[str, float, None] = "500px",
height: Union[str, float, None] = None,
summary: Union[bool, str] = True,
filters: bool = False,
row_selection_mode: Literal["none", "single", "multiple"] = "none",
Expand Down Expand Up @@ -193,6 +193,7 @@ def to_payload(self) -> Jsonifiable:
filters=self.filters,
row_selection_mode=self.row_selection_mode,
style="table",
fill=self.height is None,
)
return res

Expand Down
9 changes: 5 additions & 4 deletions shiny/www/shared/py-shiny/dataframe/dataframe.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions shiny/www/shared/py-shiny/dataframe/dataframe.js.map

Large diffs are not rendered by default.

0 comments on commit 3074eee

Please sign in to comment.