Enable and Disable RadComboBox which is placed inside the RadGrid

3 posts, 0 answers
  1. Rem
    Rem avatar
    2 posts
    Member since:
    Nov 2012

    Posted 14 Nov 2012 Link to this post

    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. Rem
    Rem avatar
    2 posts
    Member since:
    Nov 2012

    Posted 16 Nov 2012 Link to this post

    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
  3. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Nov 2012 Link to this post

    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.
Back to Top