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

Radgrid Template column enable & disable on client side

2 Answers 227 Views
Grid
This is a migrated thread and some comments may be shown as answers.
siva
Top achievements
Rank 1
siva asked on 19 May 2009, 10:33 AM
Hi,

I am having a radgrid with template columns containing checkboxes and radcombos . And the last  template column is having a radcombobox control.

On client click of checkboxes, if  checkbox is checked radcombo should be enabled , else it should be disabled.
I want to achieve this functionality by using javascript.
Any suggestions or sample code please help..


Thanks & Regards,
siva prasad.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 19 May 2009, 12:07 PM
Hello Siva,

I tried following approach for achieving the functionality. Give a try with following code.

ASPX:
 
 
<telerik:radgrid id="RadGrid1" runat="server" datasourceid="SqlDataSource1" OnItemCreated="RadGrid1_ItemCreated">  
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False">  
 
<Columns> 
<telerik:GridTemplateColumn UniqueName="TempCheckBox">  
<ItemTemplate> 
    <asp:CheckBox ID="CheckBox1" runat="server" /> 
</ItemTemplate> 
</telerik:GridTemplateColumn> 
   . . .  
<telerik:GridTemplateColumn UniqueName="TempCombo">  
<ItemTemplate> 
    <telerik:RadComboBox ID="RadComboBox2" runat="server">  
        <Items> 
            <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="RadComboBoxItem1" /> 
            <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" Value="RadComboBoxItem2" />              
        </Items> 
        <CollapseAnimation Duration="200" Type="OutQuint" /> 
    </telerik:RadComboBox> 
</ItemTemplate> 
</telerik:GridTemplateColumn> 
</Columns> 
 
</MasterTableView> 
</telerik:radgrid> 

CS:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
{  
    if (e.Item is GridDataItem)  
    {  
        GridDataItem item = (GridDataItem)e.Item;  
        CheckBox chk = (CheckBox)item.FindControl("CheckBox1");  
        RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox2");  
        chk.Attributes.Add("onclick""test(" + chk.ClientID + "," + combo.ClientID.ToString() + ")");  
    }  

JavaScript:
 
<script type="text/javascript">        
function test(cntrl , combo)  
{  
    var combobox = $find(combo.id);  
    if(cntrl.checked)  
    {  
        combobox.disable();  
    }  
    else 
    {  
        combobox.enable();  
    }      
}  
</script> 

Thanks,
Princy.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 31 Aug 2011, 02:10 PM
Hello,

Sorry,

i will add project (in code library) in couple of days.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
siva
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or