Disabled Cells
The Telerik UI Spreadsheet for ASP.NET Core 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 Core 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);
});
});
})
)
<kendo-spreadsheet name="spreadsheet">
<sheets>
<sheet name="Sheet1">
<columns>
<sheet-column>
</sheet-column>
</columns>
<rows>
<sheet-row>
<cells>
<cell value="Enabled Cell">
</cell>
<cell value="Disabled Cell" enable="false">
</cell>
</cells>
</sheet-row>
</rows>
</sheet>
</sheets>
</kendo-spreadsheet>
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);
});