Posted 24 May 2026, 4:20 am EST - Updated 25 May 2026, 1:54 am EST
Hi,
I am trying to make specific cells editable or non-editable in a TableSheet based on a row value (e.g., editable only if type === ‘item’).
To achieve this, I set locked: true in the default style of the column and applied locked: false inside StyleOptions within conditionalFormats when the formula condition =([@type]=“item”) is met.
However, the cells remain editable at all times, and the restrictions from StyleOptions.locked do not seem to take effect. It appears that StyleOptions.locked does not affect the actual cell editing state in TableSheet, even when the sheet protection option is enabled.
** StyleOptions ** https://developer.mescius.com/spreadjs/api/modules/GC.Data#styleoptions
Here is my sample code: index-table-sheet.7z
function initSpread(spread, rows) {
spread.suspendPaint();
// Add a TableSheet
const tableSheet = spread.addSheetTab(0, 'Tags', GC.Spread.Sheets.SheetType.tableSheet);
tableSheet.options.allowAddNew = false;
tableSheet.rowActionOptions([]);
// Add a DataTable
const dataManager = spread.dataManager();
const table = dataManager.addTable('TagsTable', {
batch: true,
schema: {
hierarchy: {
type: 'Level',
column: 'level'
},
columns: {
name: { dataName: 'name' },
address: { dataName: 'address' },
type: { dataName: 'type' },
level: { dataName: 'level' },
rowOrder: { dataType: 'rowOrder' },
}
},
remote: {
read: async () => window.rows,
}
});
// Load data into the DataTable
table.fetch().then(() => {
// Then, add a new DataView in the DataTable
const view = table.addView('TagsView', [
{
value: 'name',
caption: 'Name',
outlineColumn: true,
width: '*',
readonly: true, // Always read-only
},
{
value: 'address',
caption: 'Address',
width: '*',
style: {
backColor: 'Background 2',
locked: true, // Not editable
},
// Conditional formatting to make editable if type is 'item'
conditionalFormats: [{
ruleType: 'formulaRule',
formula: '=([@type]="item")',
style: {
borderLeft: { color: 'Accent 2', style: 'medium' },
borderTop: { color: 'Accent 2', style: 'medium' },
borderRight: { color: 'Accent 2', style: 'medium' },
borderBottom: { color: 'Accent 2', style: 'medium' },
backColor: 'Accent 2 80',
locked: false, // Editable
},
priority: 0,
stopIfTrue: true,
}],
},
{
value: 'type',
caption: 'Type',
width: 100,
readonly: true, // Always read-only
},
]);
// Bind the DataView with the TableSheet
tableSheet.setDataView(view);
});
How can I dynamically enable editing for specific rows based on their data? Any advice would be appreciated.
Thank you!
