New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Enable/Disable Cells



  • Home
  • Undo
  • Redo
  • Paste
  • Cut
  • Copy
  • Bold
  • Italic
  • Underline
  • Arial
  • Pick Color(Current Color is blank)
  • Pick Color(Current Color is blank)
  • All borders
    • All borders
    • Inside borders
    • Inside horizontal borders
    • Inside vertical borders
    • Outside borders
    • Left border
    • Top border
    • Right border
    • Bottom border
    • No border
  • Pick Color(Current Color is blank)
  • Horizontal alignment
    • Align Left
    • Align Center
    • Align Right
    • Justify
  • Vertical alignment
    • Align Top
    • Align Middle
    • Align Bottom
  • Wrap text
  • Merge Cells
    • Merge Cells
    • Merge Horizontally
    • Merge Vertically
    • Unmerge
  • Cut
  • Copy
  • Paste
  • Hide
  • Unhide
  • Delete
  • Hide
  • Unhide
  • Delete

The demo exhibits the ability to manage the enabled state for certain Range in the RadSpredsheet. descending or to clear the sort.

In the demo, we use the Disable 'Product' Column checkbox, in order to disable the cells in the Product column. Handling the OnClientClicked client-side event of a button and using the Client API of the RadSpreadsheet the demonstrated behavior is achieved.

        var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
        var range = spreadsheet.get_activeSheet().get_range("B3:C11");
        var isEnabled = range.get_enabled();
        range.set_enabled(!isEnabled);
        

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs"  Inherits="Spreadsheet.Examples.DisableEnableCells.DefaultCS" %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadScriptBlock runat="Server" ID="RadScriptBlock1">
        <script type="text/javascript">
            /* <![CDATA[ */
            function enableDisableColumn(sender, eventArgs) {
                var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
                var range = spreadsheet.get_activeSheet().get_range("B3:B11");
                var isEnabled = range.get_enabled();
                range.set_enabled(!isEnabled);
            }
            /* ]]> */
        </script>
    </telerik:RadScriptBlock>

    <div class="demo-container">
        <telerik:RadCheckBox runat="server" ID="RadCheckBox1" AutoPostBack="false"
            OnClientClicked="enableDisableColumn" Text="Disable 'Product' Column">
        </telerik:RadCheckBox>
        <br />
        <br />
        <telerik:RadSpreadsheet runat="server" ID="RadSpreadsheet1">
            <Toolbar>
                <telerik:SpreadsheetToolbarTab Text="Home">
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="Undo" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="Redo" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="Paste" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="Cut" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="Copy" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="Bold" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="Italic" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="Underline" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="FontFamily" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="FontSize" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="BackgroundColor" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="TextColor" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="BorderType" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="BorderColor" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="HorizontalAlignment" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="VerticalAlignment" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                    <telerik:SpreadsheetToolbarGroup>
                        <telerik:SpreadsheetTool Name="TextWrap" ShowLabel="false" />
                        <telerik:SpreadsheetTool Name="MergeCells" ShowLabel="false" />
                    </telerik:SpreadsheetToolbarGroup>
                </telerik:SpreadsheetToolbarTab>
            </Toolbar>
        </telerik:RadSpreadsheet>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance