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

Can't disable Telerik dropdown list with JQuery

1 Answer 77 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 09 Sep 2011, 04:39 PM

I'm trying to use JQuery to enable a Telerik RadComboBox based on the selection of another Telerik RadComboBox.

Use case: User comes to page, ddlRequired is enabled, ddlListItems is disabled. If user selects "Required" then I want ddlListItems to then be enabled. Conversely, if "Optional" is selected, I want to disable ddlListItems.


<telerik:RadComboBox ID="ddlRequired" runat="server" Width="80px" ShowDropDownOnTextboxClick="true" EnableEmbeddedSkins="false" Skin="Classic"  OnClientSelectedIndexChanged="OnSelectedIndexChanged">
                   
<Items>
                       
<telerik:RadComboBoxItem Text="Required" Value="1" />
                       
<telerik:RadComboBoxItem Text="Optional" Value="0" />
                   
</Items>
               
</telerik:RadComboBox>

               
<telerik:RadComboBox ID="ddlListItems" runat="server" Width="200px" ShowDropDownOnTextboxClick="true" EnableEmbeddedSkins="false" Skin="Classic" Enabled="false">
                   
<ItemTemplate>
                       
<asp:TextBox ID="txtBoxQ1" runat="server" Width="160"/>
                   
</ItemTemplate>
                   
<Items>
                       
<telerik:RadComboBoxItem />
                       
<telerik:RadComboBoxItem />
                   
</Items>
               
</telerik:RadComboBox>

Here's where I've left off after trying several approaches. I realize it's not complete.

function OnSelectedIndexChanged()
{
   
var ddl = $find("<%=ddlListItemsQ1.ClientID%>");
    ddl
.set_enabled(false);
}

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Sep 2011, 06:45 PM
Hello,

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
       <script type="text/javascript">
           function onSelectedIndexChanged(sender, eventArgs) {
               var selectedItem = eventArgs.get_item();
               var ddlListItems = $find("<%= ddlListItems.ClientID %>")
               if (selectedItem.get_value() == "1") {
                   ddlListItems.disable();
               }
               else {
                   ddlListItems.enable();
               }
           }
       </script>
   </telerik:RadCodeBlock>
<telerik:RadComboBox ID="ddlRequired" runat="server" Width="80px" OnClientSelectedIndexChanged="onSelectedIndexChanged">
            <Items>
                <telerik:RadComboBoxItem Text="Required" Value="1" Selected="true" />
                <telerik:RadComboBoxItem Text="Optional" Value="0" />
            </Items>
        </telerik:RadComboBox>
        <telerik:RadComboBox ID="ddlListItems" runat="server" Width="200px" Enabled="false">
            <Items>
                <telerik:RadComboBoxItem Text="1111" Value="1111"  />
                <telerik:RadComboBoxItem Text="2222" Value="2222" />
            </Items>
        </telerik:RadComboBox>

let me know if any concern.

Thanks,
Jayesh Goyani
Tags
ComboBox
Asked by
Rick
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or