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

Editing CheckBoxes directly in Batch Edit Mode

By default when Batch Edit mode is enabled the user needs to click on the cell first and then change its value. In some cases the users may prefer different behavior - for example when editing a boolean field that is presented by CheckBox in RadGrid.

The following example illustrates how you can change the value of a cell by clicking directly on the CheckBox in it.

<telerik:RadGrid RenderMode="Lightweight" runat="server" ID="RadGrid1"
    AllowPaging="true" PageSize="10">

    <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID" EditMode="Batch">

            <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" ReadOnly="true" InsertVisiblityMode="AlwaysVisible">
            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" ReadOnly="true">
            <telerik:GridTemplateColumn DataField="BoolField1" HeaderText="Template Column" UniqueName="BoolField1">
                    <asp:CheckBox runat="server" ID="CheckBox1" Enabled="true" Checked='<%# Eval("BoolField1") %>' onclick="checkBoxClick(this, event);" />
                    <asp:CheckBox runat="server" ID="CheckBox2" />
function checkBoxClick(sender, args) {
    var grid = $find("<%= RadGrid1.ClientID %>");
    var masterTableView = grid.get_masterTableView();
    var batchEditingManager = grid.get_batchEditingManager();
    var parentCell = $telerik.$(sender).closest("td")[0];

    var initialValue = sender.checked;
    sender.checked = !sender.checked;

    batchEditingManager.changeCellValue(parentCell, initialValue);

See Also

In this article