SelectedIndexChanged doesn't fire for items with the same name

6 posts, 0 answers
  1. Andrei
    Andrei avatar
    3 posts
    Member since:
    Mar 2014

    Posted 30 Sep Link to this post

    Hello!

    I'm having an issue with the RadComboBox control. I have noticed that when there are 2 items that have the same name, let's call them "Combo1", the event SelectedIndexChanged doesn't fire if the user is selecting the second "Combo1" while the current selection is the first "Combo1", or viceversa.

    Here's a sample with which I've reproduced the issue:

    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
        
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:scriptmanager runat="server"></asp:scriptmanager>
            
            <telerik:RadComboBox id="ComboBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ComboBox1_SelectedIndexChanged">
            <Items>
                <telerik:RadComboBoxItem Text="Combo1" />
                <telerik:RadComboBoxItem Text="Combo2" />
                <telerik:RadComboBoxItem Text="Combo1" />            
            </Items>
            </telerik:RadComboBox>
        </form>
    </body>
    </html>

     

    using System;
    using System.Web.UI;

    namespace WebApplication2
    {
        public partial class WebForm1 : Page
        {
            protected void ComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
            {
            }
        }
    }

     

    Am I doing something wrong or is this a bug? Is there a workaround that I could use in order to get it to work properly?

    Best Regards,

    Andrei

  2. Anton
    Admin
    Anton avatar
    61 posts

    Posted 30 Sep Link to this post

    Hello Andrei,

    In order to have the selection behaving correctly, you need to ensure that the Value property of the RadComboBoxItems is unique. You haven't set any values to the items of the ComboBox which leads to that behavior. More information on this matter is available in this documentation article.

    Regards,
    Anton
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrei
    Andrei avatar
    3 posts
    Member since:
    Mar 2014

    Posted 03 Oct in reply to Anton Link to this post

    Hello again,
    Thank you for the quick reply, Anton!
    Then my question is this: What do I do in case I have a TreeView control inside my ComboBox? The TreeView has a Folder->Item hierarchy, where some items will have the same name, but are under different folders. In this situation, I need the "SelectedIndexChanged" event to fire, when a user clicks a node of the tree that has the same name as the one currently selected, but is under a different Folder.( NOTE: the tree is created programmatically) As a final constraint, I cannot use the OnNodeClicked event of the TreeView in order to manually fire the "SelectedIndexChanged".

    It is a bit more difficult to provide you with o mock-up of the actual project but I can try and do that if you feel like it would help.

    Regards,

    Andrei

     

  5. Anton
    Admin
    Anton avatar
    61 posts

    Posted 03 Oct Link to this post

    Hello Andrei,

    According to the folder of the TreeView you have, you can set an unique value as we discussed. You could also consider using RadDropDownTree. More information on the RadDropDownTree you can find following the link below:

    http://docs.telerik.com/devtools/aspnet-ajax/controls/dropdowntree/overview


    Regards,
    Anton
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Andrei
    Andrei avatar
    3 posts
    Member since:
    Mar 2014

    Posted 17 Oct in reply to Anton Link to this post

    Hello Anton,

    I don't have the option of using the RadDropDownTree because it implies too much refactoring.

    I've made sure that all items have unique Values and I'm still seeing the issue. I did find an interesting pattern though. When I load the page that has the RadComboBox with the RadTreeView inside for the first time, if my currently selected value is Combo1 from folder Test1 and I go and click Combo1 from the folder Test2, the SelectedIndexChanged event fires. The "not firing" part only seems to happen after the first selection change. What I'm thinking is... maybe there's a cache somewhere in the RadComboBox control that gets populated after the first selection. Is there something like that? If so, could I clear it?

     

    Regards,

    Andrei

  7. Anton
    Admin
    Anton avatar
    61 posts

    Posted 20 Oct Link to this post

    Hello Andrei,

    The RadComboBox has item cashing functionality but it can be used only in the Load-on-demand scenario. However, it is disabled by default and that's why I presume the problem is somewhere else. Have in mind that the SelectedIndexChanged event is fired when different ComboBox items are selected. Having the RadTreeView placed in an item template counts as one item in the ComboBox. So the SelectedIndexChanged won't be fired if you click among the nodes of the TreeView. Indeed it would be fired once when you click anywhere in the TreeView, as it is an item in the ComboBox, but with having no more items, nothing will cause another execution.

    Regards,
    Anton
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017