# 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()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/spreadsheetsheetrowcellbuilder#enablesystemboolean) configuration option:

```Razor HtmlHelper
    @(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](https://docs.telerik.com/kendo-ui/api/spreadsheet/range) and the [enable](https://docs.telerik.com/kendo-ui/api/spreadsheet/range/methods/enable) method.

The following example demonstrates how to toggle the state of cell `A1` on button click:

```JS
$("#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);
});
```

## See Also

* [Disabled Cells of the Spreadsheet HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/spreadsheet/disabled-cells)
* [Server-Side API](https://www.telerik.com/aspnet-mvc/documentation/api/spreadsheet)
* [Spreadsheet Client-Side API](https://docs.telerik.com/kendo-ui/api/ui/spreadsheet)
* [kendo.spreadsheet.Sheet Client-Side API](https://docs.telerik.com/kendo-ui/api/spreadsheet/sheet)
* [kendo.spreadsheet.Range Client-Side API](https://docs.telerik.com/kendo-ui/api/spreadsheet/range)
