I can't find table
variable in your code. Is it global variable?
After removing the code, I was able to run your code successfully and toggling works as well.
table.updateOptions({
editable: !isLocked,
selectable: !isLocked
});
Please take care of this.