Disabled Cells
The Telerik UI Spreadsheet for ASP.NET MVC allows you to control the enabled and disabled state of the cells.
Set Cell State at Initialization
You can set the state of a cell during the initialization of the Spreadsheet for ASP.NET MVC by using the .Enable()
configuration option:
@(Html.Kendo().Spreadsheet()
.Name("spreadsheet")
.Sheets(sheets => {
sheets.Add()
.Name("Sheet1")
.Rows(rows => {
rows.Add().Cells(cells => {
cells.Add()
.Value("Enabled Cell");
cells.Add()
.Value("Disabled Cell")
.Enable(false);
});
});
})
)
Set Cell State after Initialization
You can set the state of a cell or range of cells after the initialization by using the kendo.spreadsheet.Range client-side API and the enable method.
The following example demosntrates how to toggle the state of cell A1
on button click:
$("#myButton").click(function () {
var range = $("#spreadsheet").data("kendoSpreadsheet").activeSheet().range("A1");
var enabled = range.enable();
if (enabled === null) {
enabled = true;
}
//Enable / disable specified range
range.enable(!enabled);
});