Completely disable a handsontable

情到浓时终转凉″ 提交于 2021-02-07 13:50:20

问题


I have just started using handsontable with JSON data and its working great but I need to disable all table input to certain users (read-only view).

Is there a way to completely disable a handsontable so none of the inputs respond and the remove row plugin doesn't function? I have tried http://dougestep.com/dme/jquery-disabler-widget-demos which doesn't seem to work and http://malsup.com/jquery/block/#element which works but it essentially creates an iframe overlay over the controls and with the removerow plugin the position is off set incorrectly.


回答1:


To fully "disable" a Handsontable I have done the following:

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:


You can do this using the updateSettings

var hot = $("#exampleGrid").handsontable('getInstance');
hot.updateSettings({
        readOnly: true
    });

Check the following link: http://jsfiddle.net/Hn3Zv/



来源:https://stackoverflow.com/questions/22453244/completely-disable-a-handsontable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!