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

[Solved] An issue with radgrid

2 Answers 134 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Soumya Joseph
Top achievements
Rank 1
Soumya Joseph asked on 18 Mar 2010, 05:05 AM
Hi,
I have a GridDropDownColumn and GridCheckBoxColumn inside  radgrid.when we select any item on GridDropDownColumn.i want the  GridCheckBoxColumn  to be enabled.Actually i couldnt find any select index change event for GridDropDownColumn .i want the client side code. Ive spent ages looking for solution but no luck .

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Mar 2010, 09:22 AM
Hello Soumya Joseph,

I achieved same functionality by attaching 'OnClientSelectedIndexChanged' event to RadComboBox control which is rendered in EditMode and setting the Checked property from client event handler. For passing the ClientID of the CheckBox I used a HiddenField.

C# code for attaching client event and saving the ClientID in HiddenField:
 
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            { 
                RadComboBox cmbCtrl = ((GridEditFormItem)e.Item)["GridDropDownColumn"].Controls[0] as RadComboBox; 
                cmbCtrl.OnClientSelectedIndexChanged = "ClientSelectedIndexChanged"
                CheckBox chkCtrl = ((GridEditFormItem)e.Item)["GridCheckBoxColumn"].Controls[0] as CheckBox; 
                hdnClientId.Value = chkCtrl.ClientID;                 
            } 
        } 

Client Code:
 
<script type="text/javascript" language="javascript"
 
        function pageLoad() {   // For setting the CheckBox as disabled initially 
            var hdn = document.getElementById("<%=hdnClientId.ClientID%>"); 
            if (hdn.value != "") { 
                var checkBox = document.getElementById(hdn.value); 
                if (checkBox) { 
                    checkBox.disabled = true
                } 
            } 
        } 
function ClientSelectedIndexChanged() { 
    var hdn = document.getElementById("<%=hdnClientId.ClientID%>"); 
    var chk = document.getElementById(hdn.value); 
    chk.disabled = false// Set as enabled 

Hope this helps,
Shinu.
0
Soumya Joseph
Top achievements
Rank 1
answered on 18 Mar 2010, 10:36 AM
Hi Shinu,
Thanks for ur help.I just did as u told me, I got an error

Unable to cast object of type 'Telerik.Web.UI.GridDataItem' to type 'Telerik.Web.UI.GridEditFormItem'.

so can please help me with this issue.
Thanks in advance
Tags
General Discussions
Asked by
Soumya Joseph
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Soumya Joseph
Top achievements
Rank 1
Share this question
or