This is a migrated thread and some comments may be shown as answers.

Disable particular cells in BatchEdit Grid

1 Answer 320 Views
This is a migrated thread and some comments may be shown as answers.
Informed Sources
Top achievements
Rank 1
Informed Sources asked on 31 Oct 2018, 12:34 AM

I have a grid, in which particular cells need to be disabled.

The enabled cells need to have a validator added to give a warning if the value isn't in a particular range, each cells range can be different

I tried disabling the cell in the PreRender, or Item created, but the edit control still appears when you tab to the cell


 protected void PriceUpdateGrid_PreRender(object sender, EventArgs e)

            foreach (GridDataItem item in PriceUpdateGrid.MasterTableView.Items)
                foreach (GridTableCell cell in item.Cells)
                   cell.Enabled = false;
                    cell.Item.Edit = false;
                //item.Enabled = false;

        protected void PriceUpdateGrid_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
            if (e.Item is GridEditableItem)
                GridEditableItem dataItem = (GridEditableItem)e.Item;
                (e.Item as GridEditableItem)["377"].Enabled = false;
                dataItem["377"].Enabled = false;
                dataItem["377"] = false;
                dataItem["377"].Controls[0].Enabled = false;
                dataItem["377"].Visible = false;





 <telerik:RadGrid ID="PriceUpdateGrid" runat="server" RenderMode="Lightweight" ViewStateMode="Enabled"
        AllowSorting="False" GridLines="None" ShowGroupPanel="False" Skin="WebBlue" AutoGenerateColumns="False"
        OnNeedDataSource="PriceUpdateGrid_NeedDataSource" AllowMultiRowSelection="True"
        <PagerStyle AlwaysVisible="False" />
        <MasterTableView ClientDataKeyNames="SurveyEntityId" EnableViewState="true" DataKeyNames="SurveyEntityId,SubRegionSiteId" EditMode="Batch" CommandItemDisplay="TopAndBottom">
            <BatchEditingSettings EditType="Cell"></BatchEditingSettings>
                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="40px">
                <HeaderStyle Width="20px"></HeaderStyle>
                <HeaderStyle Width="20px"></HeaderStyle>


        <ClientSettings EnableRowHoverStyle="true" AllowKeyboardNavigation="true">
            <ClientEvents OnBatchEditOpening="BatchEditOpening" />
            <Resizing AllowColumnResize="true" />
            <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="True" />
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />

1 Answer, 1 is accepted

Sort by
Attila Antal
Telerik team
answered on 01 Nov 2018, 09:01 PM

RadGrid with BatchEditing is designed entirely for client-side, and so if you wish to manipulate it, try using the Batch Editing Client-side API and Client-Side Programming Overview. One example would be to subscribe the grid to its OnBatchEditOpening client-side event, and in the event handler you can check column-cell is about to be edited. Cancel the event if necessary. That will prevent a cell from opening.

If you wish to perform other logic on the cell, you might want to loop through the Grid rows using the GridCreated client-side event, get access to the cell and run your logic. Check out the Accessing Controls in Batch Edit Mode article for more.

Kind regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Informed Sources
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question