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

check box not editable by client

3 Answers 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 28 Dec 2011, 06:47 PM
Hey I am having a problem with a rad grid.  i am adding columns programmatically and setting a datasource in the

 

NeedDataSource event.  The problem is that i can't seem to "unlock" the checkbox column so that the user can check/uncheck the field.  what am i missing?  i can't find anything in docs describing how to do this.  i have made grid item edtible on pre render - to no effect; i have made readonly property false - also to no effect.  please help.

it is embedded in a user control like below

 

<% @ Control Language="C#" AutoEventWireup="true" CodeFile="ActiveFileTable.ascx.cs" Inherits="ActiveFileTable" %>

 

<asp:Panel ID="Panel1" runat="server" Height="531px" Width="865px">

 

<telerik:RadGrid ID="RadGrid1" runat="server">

 </telerik:RadGrid>

 

</asp:Panel>

 

 c#

 dataLayerDataContext dataLayer = new dataLayerDataContext();

RadGrid1.AutoGenerateColumns = false;

GridCheckBoxColumn boundColumn4 = new GridCheckBoxColumn();

boundColumn4.UniqueName = "Is Active";

boundColumn4.DataField = "isactive";

boundColumn4.HeaderText = "Active";

boundColumn4.Visible = true;

boundColumn4.ReadOnly = false;

 

RadGrid1.MasterTableView.Columns.Add(boundColumn4);

RadGrid1.DataSource = dataLayer.getActiveInvFilePT();

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard
Top achievements
Rank 1
answered on 28 Dec 2011, 10:02 PM
Chris:

Take a look at the RadGrid Span around Checkbox disabled forum thread. It deals with a somewhat similar issue and should provide some insights to a solution here.

Cheers!
0
Shinu
Top achievements
Rank 2
answered on 29 Dec 2011, 05:01 AM
Hello Chris,

When the grid is in browser mode, or if the column is read-only, the check box is disabled. When the column is editable, the check box is enabled. Check the following help documentation which explains the same.
Column Types

-Shinu.
0
Chris
Top achievements
Rank 1
answered on 29 Dec 2011, 04:51 PM

I ended up solving the problem by adding the below event handler.  thanks!

RadGrid1.ItemDataBound += new Telerik.Web.UI.GridItemEventHandler(this.RadGrid1_itemDataBound);

 

private void RadGrid1_itemDataBound(object sender, GridItemEventArgs e)

 {

 

if (e.Item is GridDataItem)

 {

   GridDataItem dataItem = (GridDataItem)e.Item;

    CheckBox chkBox = (CheckBox)dataItem["IsActive"].Controls[0];

     chkBox.Enabled =  true; // enable CheckBox

 }

 

}

Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Chris
Top achievements
Rank 1
Share this question
or