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

ComboBox using EnableLoadOnDemand not retaining user selection when changed

13 Answers 112 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Robert Helm
Top achievements
Rank 1
Robert Helm asked on 30 May 2013, 09:30 PM
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

13 Answers, 1 is accepted

Sort by
0
Robert Helm
Top achievements
Rank 1
answered on 31 May 2013, 01:28 PM
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();
 }
0
Nencho
Telerik team
answered on 04 Jun 2013, 11:31 AM
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.
0
Robert Helm
Top achievements
Rank 1
answered on 04 Jun 2013, 09:00 PM
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
0
Robert Helm
Top achievements
Rank 1
answered on 06 Jun 2013, 02:25 PM
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
0
Nencho
Telerik team
answered on 10 Jun 2013, 06:50 AM
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.
0
Robert Helm
Top achievements
Rank 1
answered on 10 Jun 2013, 12:35 PM
Thanks Nencho,

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

Thanks,
Robert
0
Robert Helm
Top achievements
Rank 1
answered on 12 Jun 2013, 01:46 PM
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
0
Nencho
Telerik team
answered on 13 Jun 2013, 12:10 PM
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.
0
Robert Helm
Top achievements
Rank 1
answered on 13 Jun 2013, 12:54 PM
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 
0
Robert Helm
Top achievements
Rank 1
answered on 13 Jun 2013, 07:30 PM
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
0
Nencho
Telerik team
answered on 14 Jun 2013, 02:24 PM
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.
0
Leo
Top achievements
Rank 2
answered on 19 Jul 2013, 07:02 PM
Hi there,

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

Best,

Long
0
Robert Helm
Top achievements
Rank 1
answered on 19 Jul 2013, 08:33 PM
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)


Tags
ComboBox
Asked by
Robert Helm
Top achievements
Rank 1
Answers by
Robert Helm
Top achievements
Rank 1
Nencho
Telerik team
Leo
Top achievements
Rank 2
Share this question
or