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

Enable and Disable RadComboBox which is placed inside the RadGrid

2 Answers 827 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rem
Top achievements
Rank 1
Rem asked on 14 Nov 2012, 10:27 AM
Hi, I have  place RadCombo  inside RADGRID like this
<telerik:GridTemplateColumn   HeaderStyle-HorizontalAlign ="Center" UniqueName="Field" >  
                    <ItemTemplate >
                     <telerik:RadComboBox ID="dropdownfield" runat="server" 
                        EmptyMessage="Choose an instance column" HighlightTemplatedItems="true" AllowCustomText="true"
                        EnableLoadOnDemand="false" EnableVirtualScrolling="true" Filter="Contains" Visible="true" Enabled="false"
                        DropDownWidth="600px" Width="600px"  Skin="WebBlue">
                                <HeaderTemplate>
                                <table cellspacing="0" cellpadding="0">
                                    <tr>
                                          <td style="width:300px;">
                                           Column Name</td>                                    
                                    </tr>
                                </table>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <table  cellspacing="0" cellpadding="0">
                                    <tr>                                        
                                            <td style="width:300px;">
                                            <%# DataBinder.Eval(Container.DataItem, "FieldName")%>
                                        </td>                                                                             
                                    </tr>
                                </table>
                            </ItemTemplate>
    </telerik:RadComboBox>

Below is my javascript to enable/disable RadComboBox 

 function EnableDisbledropdown(chkbox, index) {
         var grid = $find("<%= raggrid.ClientID %>");
        var masterTableView = grid.get_masterTableView();
        var item = masterTableView.get_dataItems()[index];     // here i'm getting specific row of that grid 
        var combo= item.findControl("dropdownfield");
      
         if (chkbox.checked) {
                 combo.enable(); /* for RadComboBox  */
        }
        else {
               combo.disable(); /* for RadComboBox  */
        }

Well my scenerio is that when user check the checkbox Control of that specific row , that corresponding RadComboBox has to be get enabled.
When i run the code i got this following error msg:-
"Object doesn't support this property or method 'enable'

Can someone please  show me how to achieved that functionality ?




2 Answers, 1 is accepted

Sort by
0
Rem
Top achievements
Rank 1
answered on 16 Nov 2012, 09:24 AM
Well Let me simply what my scenerio is. There are two columns in radGrid one column is filled with Checkbox control  and other column is filled with Radcombobox control  . So when user check the checkbox Control of that specific row , that corresponding RadComboBox has to be get enabled,by default  Radcombobox is disabled.   It is working properly  in server side but i'm not getting at the client side

Here is  my javascript to enable/disable RadComboBox 

 function EnableDisbledropdown(checkbox, index) {
         var grid = $find("<%= raggrid.ClientID %>");
        var masterTableView = grid.get_masterTableView();
        var item = masterTableView.get_dataItems()[index];     // here getting specific row of that grid 
         var combo= item.findControl("combobox");
              if (checkbox.checked) {  
                 combo.enable(); 
        }
        else {
               combo.disable(); 
        }

I would be more appreciate if Telerik people show some solution on this one
0
Shinu
Top achievements
Rank 2
answered on 16 Nov 2012, 11:51 AM
Hi,

I have made some modifications in your code. Here is the full code that I tried.
aspx:
<telerik:GridTemplateColumn>
 <ItemTemplate>
  <telerik:RadComboBox  ID="RadComboBox1" runat="server">
    <Items>
      <telerik:RadComboBoxItem Text="RadComboBoxItem1" />
      <telerik:RadComboBoxItem Text="RadComboBoxItem2" />
    </Items>
  </telerik:RadComboBox>
 </ItemTemplate>
 </telerik:GridTemplateColumn>
<telerik:GridTemplateColumn >
   <ItemTemplate>
      <asp:CheckBox ID="CheckBox1"  runat="server" />
   </ItemTemplate>
</telerik:GridTemplateColumn>
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        CheckBox chk = (CheckBox)item.FindControl("CheckBox1");
        chk.AutoPostBack = false;
        chk.Attributes.Add("onclick", "Click('" + item.ItemIndex + "');");
  }
}
JS:
function Click(index)
{
 var grid = $find("<%= RadGrid1.ClientID %>");
 var masterTableView = grid.get_masterTableView();
 var item = masterTableView.get_dataItems()[index];
 var combo = item.findControl("RadComboBox1");
 var chkbox = item.findElement("CheckBox1");
 if (chkbox.checked==true)
 {
    combo.enable();
 }
   else
   {
       combo.disable();
   }
}

Thanks,
Shinu.
Tags
ComboBox
Asked by
Rem
Top achievements
Rank 1
Answers by
Rem
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or