完全禁用handsontable

问题描述 投票:0回答:3

我刚刚开始使用带有 JSON 数据的 handsontable,它工作得很好,但我需要禁用某些用户的所有表输入(只读视图)。

有没有办法完全禁用 Handsontable,这样所有输入都没有响应,并且删除行插件也不起作用?我已经尝试过 http://dougestep.com/dme/jquery-disabler-widget-demos 似乎不起作用,而 http://malsup.com/jquery/block/#element 则有效,但它本质上是在控件上创建一个 iframe 覆盖层,并且使用 removerow 插件,位置偏移设置不正确。

javascript jquery handsontable
3个回答
19
投票

要完全“禁用”Handsontable,我已执行以下操作:

hot.updateSettings({
    readOnly: true, // make table cells read-only
    contextMenu: false, // disable context menu to change things
    disableVisualSelection: true, // prevent user from visually selecting
    manualColumnResize: false, // prevent dragging to resize columns
    manualRowResize: false, // prevent dragging to resize rows
    comments: false // prevent editing of comments
});

2
投票

您可以使用 updateSettings

来执行此操作
var hot = $("#exampleGrid").handsontable('getInstance');
hot.updateSettings({
        readOnly: true
    });

检查以下链接: http://jsfiddle.net/Hn3Zv/


0
投票

                             height="auto"
                             width="auto"
                             colHeaders={true}
                             rowHeaders={true}
                             minSpareRows={0}
                             readOnly={true}
                             licenseKey="non-commercial-and-evaluation"
                             cells={(row, col) => getCellProps(row, col)}
                          />
© www.soinside.com 2019 - 2024. All rights reserved.