ComboBox using EnableLoadOnDemand not retaining user selection when changed

14 posts, 0 answers
  1. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 30 May 2013 Link to this post

    I have several ComboBoxes employing the EnableLoadOnDemand mode.

    If the user chooses an item where the ItemDescriptionShort and ItemDescriptionLong fields are different lengths, the selection is not saved. The ComboBox.SelectedValue gets set to blank in this case.

    On the server side: User start typing or scrolling the ComboBox. We pull data from the database and set each item's value (ItemCode), then set the item's text (ItemDescriptionLong). Then add 2 attributes to the item, DescShort (ItemDescriptionShort), and Code (ItemCode).

    On the client side: User selects an item. We pull the aforementioned attributes (DescShort, Code) and use them to set the ComboBox's text and value. Setting ComboBox's text = DescShort (ItemDescriptionShort), and setting the ComboBox's value to ItemCode.

    Somewhere after this, ComboBox's SelectedValue becomes blank if the user has selected an item where the ItemDescriptionShort and ItemDescriptionLong differ in length.


    This worked without issue until we upgraded to Telerik version 2013.1.403.40.

    Is this a breaking change that I missed, is it a bug, or am I doing something wrong employing the EnableOnDemand mode? There is a lot of code to change.

    Thanks,
    Robert
  2. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 31 May 2013 Link to this post

    Client Side code:

    function OnClientSelectedIndexChanged(sender, eventArgs) {
        if (sender.get_value() != "") {
            var item = sender.get_selectedItem();
            var descShort = item.get_attributes().getAttribute("DescShort");
            var code = item.get_attributes().getAttribute("Code");
            sender.set_text(code + " " + descShort);
            sender.set_value(code);
        }
    }

    Server Side Code:

    for (int i = itemOffset; i < endOffset; i++)
    {          
                RadComboBoxItem item = new RadComboBoxItem();
                item.Text = dl[i].ItemCode + " " + dl[i].ItemDescriptionLong;
                item.Value = dl[i].ItemCode;
                item.Attributes.Add("DescShort", dl[i].ItemDescriptionShort);
                item.Attributes.Add("Code", dl[i].ItemCode);
                ((RadComboBox)sender).Items.Add(item);
                item.DataBind();
     }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 04 Jun 2013 Link to this post

    Hello Robert,

    I have performed some tests, trying to replicate the described problem, but to no avail. I have prepared a sample project for you, demonstrating the behavior at my end. Would you give it a try at your side, and let me know if I had missed something? If possible, please modify it in a manner, so we could observe the issue at our side.

    Note : dll files are removed from the attachment.

    Regards,
    Nencho
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 04 Jun 2013 Link to this post

    Thanks Nencho,

    I modified your code by removing the ComboBox property AutoPostBack="true" or setting it to "false".
    I also added a button and label. Clicking the button will display the ComboBox.SelectedValue.

    If you do that, you'll notice that when you select an item in the list it displays the short description, but once you lose focus (click the button, etc), it reverts back to the long description, and the ComboBox.SelectedValue becomes blank.

    Please try this and let me know what you think. Again, this was working in the version previous to 2013.1.403.40.

    Thanks,
    Robert
  6. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 06 Jun 2013 Link to this post

    Hello again Nencho,

    So far I haven't found any workaround for this issue (setting AutoPostBack="true" is not an option on most of our pages).

    Does Telerik have any suggestions for a workaround? Also, is this considered an issue with Telerik's release since it was working as expected previously?

    Thanks for any info,
    Robert
  7. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 10 Jun 2013 Link to this post

    Hello Robert,

    I have performed some tests, trying to reproduce the behavior you experience at your end, but to no avail. Here is video, demonstrating the behavior at my end. Would you also record a video, using Jing, demonstrating the problem at your side. In addition, would you specify which browser do you use?

    Regards,
    Nencho
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  8. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 10 Jun 2013 Link to this post

    Thanks Nencho,

    I can still reproduce the issue and as you requested, here is a video showing it.

    Thanks,
    Robert
  9. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 12 Jun 2013 Link to this post

    Hi Nencho,

    As you can tell from the videos, you and I have everything the same, presumably. One thing we might have different is the Telerik DLL. As mentioned initially, I am using 2013.1.403.40. I assume you are using the same for that project/video, but it's something to check.

    Thanks,
    Robert
  10. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 13 Jun 2013 Link to this post

    Hello Robert,

    I confirm that the used version is 2013.1.403.40. Here is another video, demonstrating the behavior at my end.

    Regards,
    Nencho
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  11. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 13 Jun 2013 Link to this post

    Hi Nencho,

    You have AutoPostback="True" again for the ComboBox's property. If it's set to "False" the issue arises for us (per my previous video). Is it just in my court now to figure out why it's not working with this version? I mean I guess I'm asking if there's something else you might need from me to help you all diagnose the problem there since we're using the same project and code that you had sent.

    Thanks for any info,
    Robert 
  12. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 13 Jun 2013 Link to this post

    Hi Nencho,

    I've prepared 2 videos. Both use the same simple project but the first one uses Telerik version 2012.3.1308.40 and there is no issue. The second video uses Telerik version 2013.1.403.40 and there is an issue.

    No issue: Version 2012.3.1308.40 works

    Issue: Version 2013.1.403.40 does not work

    Also, I tried the latest version (2013.2.611.40) as well and it doesn't work either.

    Thanks,
    Robert
  13. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 14 Jun 2013 Link to this post

    Hello Robert,

    I had already answered to your other support ticket, regarding the same topic. Therefore, I would like to ask you to continue the conversation in the other ticket.

    Regards,
    Nencho
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  14. Leo
    Leo avatar
    6 posts
    Member since:
    Jun 2013

    Posted 19 Jul 2013 Link to this post

    Hi there,

    I'm having exactly the same error, and I wonder if you can share the workaround solution here. Thank you!

    Best,

    Long
  15. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 19 Jul 2013 Link to this post

    Hi Long,

    I had to modify my server side code (original is above). I needed to set the list item's value to something different than what I'm setting it to on the client side. Because (from Nencho's reply to my ticket) "The RadComboBox internal functionality is to get the current selectedValue and search for the first item matching this value and set it as selected. This is the reason why, each time you alter the Text and Value of the RadComboBox, the Item with the set value is preselected. I would suggest you to have different Value of the items, regarding their Code attribute values. "

    In short, the only thing I changed server side in the code below is adding something, anything, to the item.Value:
    item.Value = "Anything here. It gets reset correctly client side" + dl[i].ItemCode;


    New Server Side Code:
    for (int i = itemOffset; i < endOffset; i++)
    {RadComboBoxItem item = new RadComboBoxItem();
     item.Text = dl[i].ItemCode + " " + dl[i].ItemDescriptionLong;
     item.Value = "Anything here. It gets reset correctly client side" + dl[i].ItemCode;
     item.Attributes.Add("DescShort", dl[i].ItemDescriptionShort);
     item.Attributes.Add("Code", dl[i].ItemCode);
     ((RadComboBox)sender).Items.Add(item);
     item.DataBind();
     }


    Still don't know why it worked fine before the upgrade and doesn't since, but this appears to be working for us.

    Hope it helps.
    Robert (via Nencho)


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017