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"
OnPreRender="PriceUpdateGrid_PreRender"
OnItemCreated="PriceUpdateGrid_ItemCreated"
OnItemUpdated="PriceUpdateGrid_ItemUpdated"
OnItemDataBound="PriceUpdateGrid_ItemDataBound"
OnBatchEditCommand="PriceUpdateGrid_BatchEditCommand"
AllowAutomaticUpdates="True">
<PagerStyle AlwaysVisible="False" />
<MasterTableView ClientDataKeyNames="SurveyEntityId" EnableViewState="true" DataKeyNames="SurveyEntityId,SubRegionSiteId" EditMode="Batch" CommandItemDisplay="TopAndBottom">
<BatchEditingSettings EditType="Cell"></BatchEditingSettings>
<Columns>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="40px">
</telerik:GridClientSelectColumn>
</Columns>
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true" AllowKeyboardNavigation="true">
<ClientEvents OnBatchEditOpening="BatchEditOpening" />
<Resizing AllowColumnResize="true" />
<Selecting AllowRowSelect="True" UseClientSelectColumnOnly="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
</telerik:RadGrid>