fix editable property of columns being ignored in data_editor (#2338)

This commit is contained in:
Thomas Brandého 2023-12-28 09:09:07 +01:00 committed by GitHub
parent c5c42665eb
commit 78429866bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { GridCellKind } from "@glideapps/glide-data-grid"
import { GridCellKind } from "@glideapps/glide-data-grid";
export function getDEColumn(columns, col) {
let c = columns[col];
@ -19,7 +19,7 @@ export function locateCell(row, column) {
}
export function formatCell(value, column) {
const editable = column.editable || true
const editable = column.editable ?? true;
switch (column.type) {
case "int":
case "float":
@ -29,7 +29,7 @@ export function formatCell(value, column) {
displayData: value + "",
readonly: !editable,
allowOverlay: editable,
}
};
case "datetime":
// value = moment format?
case "str":
@ -39,22 +39,24 @@ export function formatCell(value, column) {
displayData: value,
readonly: !editable,
allowOverlay: editable,
}
};
case "bool":
return {
kind: GridCellKind.Boolean,
data: value,
readonly: !editable,
}
};
default:
console.log("Warning: column.type is undefined for column.title=" + column.title)
console.log(
"Warning: column.type is undefined for column.title=" + column.title
);
return {
kind: GridCellKind.Text,
data: value,
displayData: column.type
}
displayData: column.type,
};
};
}
}
export function formatDataEditorCells(col, row, columns, data) {
if (row < data.length && col < columns.length) {