You can lock a cell or several cells to protect their content from editing. The locked cells will have a small yellow lock in the bottom right corner.
For this purpose, you need to use the lockCell method and pass three parameters to it:
// locks the cell at the intersection of the 3rd row and 2nd column
$$("ssheet").lockCell(3, 2, true);
You can also lock/unlock several cells at a time with the lockCell method. Call it with different parameters:
// locks 7 cells in the 2nd row
$$("ssheet").lockCell({ row:2, column:1 }, { row:2, column:7 }, true);
// locks 7 cells in the 2nd column
$$("ssheet").lockCell({ row:1, column:2 }, { row:7, column:2 }, true);
// locks 10 cells in the 1st and 2nd rows
$$("ssheet").lockCell({ row:1, column:1 }, { row:2, column:5 }, true);
In case the cell/cells to lock aren't specified, the method will lock the selected cell.
You can modify the default styling of locked cells, by disabling yellow locks and applying some background color via CSS:
<style>
.webix_lock:after{
content:" ";
}
.webix_lock {
background-color:#99f29d;
}
</style>
Related sample: Styling locked cells
You can check, whether a cell is locked, with the help of the isCellLocked method.
It takes two parameters:
and returns true, if the cell is locked and false if it's unlocked.
var isLocked = $$("ssheet").isCellLocked(3, 2);
It's possible to add an editor into a cell of the sheet. It can include either some custom options or values of a cell range. You can also explicitly specify whether to add an empty option.
Use the setCellEditor to do it. The method expects three parameters:
$$("ss1").setCellEditor(8,1,{ editor:"ss_richselect", options:["One", "Two", "Three"]});
// or
$$("ss1").setCellEditor(8,2,{ editor:"ss_richselect", options:"B3:B7", empty:true });
You can get the editor set in a cell with the help of the getCellEditor method.
The method takes the ids of cell's row and column as parameters.
$$("ss1").getCellEditor(8,1);
It will return an object with two properties:
{editor:"ss_richselect", options:["One","Two","Three"]}
// or
{editor:"ss_richselect", options:"B3:B7"}
You can also set a filter inside of a cell. The method setCellFilter will help your with this task.
You need to pass the following parameters to this method:
// an array of options
$$("ss1").setCellFilter(1,2, ["", "Europe", "Asia", "America"]);
// a range of cells references
$$("ss1").setCellFilter(2,2, "B3:B7");
SpreadSheet allows you to sort values within a selected or specified range of cells via the sortRange method. You can pass two optional parameters to it:
// sorts the specified range in the default ("asc") order
$$("ssheet").sortRange("B2:B4");
// sorts the specifed range in the descending order
$$("ssheet").sortRange("B2:B4", "desc");
// sorts the selected range in the descending order
$$("ssheet").sortRange(null,"desc");
You can add a small chart into a cell to display tendencies of data values changing in a range of cells.
To insert a sparkline inside of a cell, use the addSparkline method with the following parameters:
$$("ssheet").addSparkline(rowId, columnId, config);
Let's insert a blue sparkline of the Line type into the cell E5. The passed parameters will be as follows:
$$("ssheet").addSparkline(5,5,{type:"line", range:"B4:E4", color:"#6666FF"});
Related sample: Adding sparklines
You can add an image into a cell to illustrate data in the spreadsheet.
To insert an image into a cell, use the addImage method. You need to pass three parameters to this method:
$$("ssheet").addImage(2,3, "http://docs.webix.com/media/desktop/image.png");
There is a possibility to add a comment into a certain cell of SpreadSheet.
Use the add() method of the comments object. It takes three parameters:
// adding a comment into the cell B3
$$("ssheet").comments.add(3,2,"text");
The API of the comments object also makes it possible to get a comment of a particular cell or to delete a comment that is no longer needed:
// getting a comment for the cell B3
$$("ssheet").comments.get(3,2);
// removing a comment from the cell B3
$$("ssheet").comments.remove(3,2);
You can specify what data will be displayed in the SpreadSheet cells by using placeholders.
A placeholder is an object with data properties which can be set as SpreadSheet values. To define a placeholder use the setPlaceholder method:
$$("ssheet").setPlaceholder({value:"France", expense:1366, income:842});
To specify a placeholder's property in a cell instead of a value, use the ={{property}} construction. For example, for cells with the "expense" values you should specify placeholders as "={{expense}}".
If you specify a new placeholder for a SpreadSheet, values of all cells where properties of this placeholder are defined will be updated.
$$("ssheet").setPlaceholder({value:"Poland", expense:684, income:781});
Back to top