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

table col width #2358

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/taipy-gui/packaging/taipy-gui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ export interface ColumnDesc {
lov?: string[];
/** If true the user can enter any value besides the lov values. */
freeLov?: boolean;
/** If true, the column cannot be sorted */
notSortable?: boolean;
/** If false, the column cannot be sorted */
sortable?: boolean;
}
/**
* A cell value type.
Expand Down
8 changes: 4 additions & 4 deletions frontend/taipy-gui/src/components/Taipy/AutoLoadingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ const AutoLoadingTable = (props: TaipyTableProps) => {
if (nDesc.tooltip === undefined) {
nDesc.tooltip = props.tooltip;
}
if (typeof nDesc.notSortable != "boolean") {
nDesc.notSortable = !sortable;
if (typeof nDesc.sortable != "boolean") {
nDesc.sortable = sortable;
}
});
addActionColumn(
Expand Down Expand Up @@ -706,8 +706,8 @@ const AutoLoadingTable = (props: TaipyTableProps) => {
direction={orderBy === columns[col].dfid ? order : "asc"}
data-dfid={columns[col].dfid}
onClick={onSort}
disabled={!active || columns[col].notSortable}
hideSortIcon={!active || columns[col].notSortable}
disabled={!active || !columns[col].sortable}
hideSortIcon={!active || !columns[col].sortable}
>
<Box sx={headBoxSx}>
{columns[col].groupBy ? (
Expand Down
14 changes: 9 additions & 5 deletions frontend/taipy-gui/src/components/Taipy/PaginatedTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ const PaginatedTable = (props: TaipyPaginatedTableProps) => {
if (nDesc.tooltip === undefined) {
nDesc.tooltip = props.tooltip;
}
if (typeof nDesc.notSortable != "boolean") {
nDesc.notSortable = !sortable;
if (typeof nDesc.sortable != "boolean") {
nDesc.sortable = sortable;
}
});
addActionColumn(
Expand All @@ -173,6 +173,7 @@ const PaginatedTable = (props: TaipyPaginatedTableProps) => {
);
const colsOrder = Object.keys(newCols).sort(getSortByIndex(newCols));
let nbWidth = 0;
let widthRate = 0;
const functions = colsOrder.reduce<Record<string, Record<string, string>>>((pv, col) => {
if (newCols[col].className) {
pv.classNames = pv.classNames || {};
Expand All @@ -192,6 +193,9 @@ const PaginatedTable = (props: TaipyPaginatedTableProps) => {
if (cssWidth) {
newCols[col].width = cssWidth;
nbWidth++;
if (cssWidth.endsWith("%")) {
widthRate += parseInt(cssWidth, 10);
}
}
}
return pv;
Expand All @@ -210,7 +214,7 @@ const PaginatedTable = (props: TaipyPaginatedTableProps) => {
hNan,
filter,
partialEditable,
nbWidth > 0 ? `${100 / nbWidth}%` : undefined
nbWidth > 0 ? `${(100 - widthRate) / nbWidth}%` : undefined
];
} catch (e) {
console.info("PaginatedTable.columns: ", (e as Error).message || e);
Expand Down Expand Up @@ -585,8 +589,8 @@ const PaginatedTable = (props: TaipyPaginatedTableProps) => {
direction={orderBy === columns[col].dfid ? order : "asc"}
data-dfid={columns[col].dfid}
onClick={onSort}
disabled={!active || columns[col].notSortable}
hideSortIcon={!active || columns[col].notSortable}
disabled={!active || !columns[col].sortable}
hideSortIcon={!active || !columns[col].sortable}
>
<Box sx={headBoxSx}>
{columns[col].groupBy ? (
Expand Down
4 changes: 2 additions & 2 deletions frontend/taipy-gui/src/components/Taipy/tableUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export interface ColumnDesc {
lov?: string[];
/** If true the user can enter any value besides the lov values. */
freeLov?: boolean;
/** If true, the column cannot be sorted */
notSortable?: boolean;
/** If false, the column cannot be sorted */
sortable?: boolean;
}

export const DEFAULT_SIZE = "small";
Expand Down
4 changes: 2 additions & 2 deletions taipy/gui/viselements.json
FredLL-Avaiga marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@
{
"name": "width[<i>column_name</i>]",
"type": "str",
"doc": "The width of the indicated column, in CSS units."
"doc": "The width of the indicated column, in CSS units (% values are not supported)."
},
{
"name": "selected",
Expand Down Expand Up @@ -1081,7 +1081,7 @@
"name": "sortable",
"type": "bool",
"default_value": "True",
"doc": "TODO: Indicates, if False, that the table cannot be sorted. (can be overridden on a column basis by specifying notSortable key in the columns dict."
"doc": "If False, the table provides no sorting capability. (TO BE DISCUSSED: can be overridden on a column basis by specifying sortable key in the columns dict."
FredLL-Avaiga marked this conversation as resolved.
Show resolved Hide resolved
}
]
}
Expand Down
Loading