NEW VERSION RELEASED! Webix 11 Read More Core Updates, Extended Functionalities in SpreadSheet and File Manager and more

Cell Locking, JavaScript Programming Example of Cell Locking in SpreadSheet

JavaScript Programming Example of Cell Locking in SpreadSheet

Check out our programming example of how you can enable cell locking in SpreadSheet. Feel free to download this piece of code and apply it to your app.

JS Code

webix.ready(function(){

  function lock(){
    var ids = $$("ssheet").getSelectedId(true);
    if(!ids.length)
      $$("ssheet").alert({text: "Please, select at least one cell."});
    else{
      var state = $$("ssheet").isCellLocked(ids[0].row, ids[0].column);
      if(ids.length == 1) //lock a single cell
        $$("ssheet").lockCell(ids[0].row, ids[0].column, !state);
      else  //lock cell range
        $$("ssheet").lockCell(ids[0], ids[ids.length-1], !state);
    }
  }

  webix.ui({
    rows:[
      { view:"button", label: "Lock / unlock cell", inputWidth:200, click: lock},
      {
        view:"spreadsheet",
        id:"ssheet",
        toolbar: "full",
        data:{
          data:[
            [3,2,"Webix"],
            [3,3,"SpreadSheet"]
          ]
        }
      }
    ]
  });
});

Would you like to be able to enable cell locking in your spreadsheet?