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

Existing value (get_value() or SelectedValue()) retained even after user deletes it from list.

3 Answers 202 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 13 Jan 2015, 09:23 PM

I have a RadComboBox and I fill it on demand as the user types. No problems.
Now, if the ComboBox has an existing value on page load, and the user deletes it (via "x" or backspace),
the client-side .get_value() and the server-side.SelectedValue() still show the old value.

This is a problem because I check the value before saving, etc. In essence, the user deletes the value (text = "") but it still saves because the checks (client or server) show the value as still being there.

This was working for some time but has broken recently in our Prod version (2013.3.1324 - Q3 2013 SP2 ) and our Test/QA version (latest 2014.3.1209 - Q3 2014 SP1).

Client-side code below:

<telerik:RadComboBox ID="ddlPName" runat="server" CssClass="cert" Width="269px" Height="150px"
 CollapseAnimation-Duration="0" CollapseDelay="0" CloseDropDownOnBlur="true" Skin="Vista"
 EmptyMessage="Type Name" EnableLoadOnDemand="True" ShowMoreResultsBox="true"
 EnableVirtualScrolling="true" OnItemsRequested="ddlPName_ItemsRequested" DropDownWidth="269"
 MarkFirstMatch="false" OnClientSelectedIndexChanged="NameSelectedIndexChanged"
 OnClientDropDownOpened="onClientDropDownOpened" OnClientDropDownClosed="ddlPName_OnClientDropDownClosed"
 OnClientItemsRequestFailed="OnComboCallbackError" OnClientItemsRequesting="onItemsRequesting"
 OnClientTextChange="OnDDLTextChange">

</telerik:RadComboBox>function OnDDLTextChangeICD9(sender, args) {
 if (sender.get_value() == "") {
  sender.set_text("");
 }
}


Thanks for any ideas,
Robert




3 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 16 Jan 2015, 11:39 AM
Hello Robert,

I tried to replicate the described issue, but I am afraid to no avail. Could you specify how do you set the value of the RadComboBox at Page_Load. In addition, I am sending you the simple page, that I have tested with. Could you please give it a try at your end and modify it in a manner so we could replicate the described issue locally. Thus we would be able to pinpoint the problem and troubleshoot it for you.

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Robert Helm
Top achievements
Rank 1
answered on 16 Jan 2015, 02:15 PM
Thanks for the reply Nencho.
I load the RadComboBox from the page load like so... 

-----------------------------
protected void Page_Load(object sender, EventArgs e)
 {
   if (!(Page.IsPostBack))
   {
    ddlPName.SelectedValue = datasource.value;
    ddlPName.Text = datasource.text;
   }
 }
-----------------------------

But this is an "on demand" as well, using OnItemsRequested to call a server side method to populate the RadComboBox with 10 items at a time as the user types...   
-----------------------------
protected void ddlPName_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {      
        ClassNameList pl = GetNameList();
        int itemOffset = e.NumberOfItems;
        int endOffset = Math.Min(itemOffset + ItemsPerRequest, pl.Count);
        e.EndOfItems = endOffset == pl.Count;
       
        for (int i = e.NumberOfItems; i < endOffset; i++)
        {       
            RadComboBoxItem item = new RadComboBoxItem();
            item.Text = pl[i].NameCode + " " + pl[i].FullName;
            item.Value = "NameCode" + pl[i].NameCode;
            item.Attributes.Add("DescShort", pl[i].ShortName);
            item.Attributes.Add("Code", pl[i].NameCode);
            ((RadComboBox)sender).Items.Add(item);
            item.DataBind();
        }
       
        e.Message = GetStatusMessage(endOffset, pl.Count);
    }
-----------------------------

For what it's worth, I modified the client-side method to get_text() as well as the get_value(). The value still shows even after the text is deleted, but since the text is gone the method evaluates to true and I get in to clear the text. Which interestingly enough, clears the value because when I check server side the value is gone. 
-----------------------------
function OnDDLTextChange(sender, args) {
  //if (sender.get_value() == "") {
  if (sender.get_value() == "" || sender.get_text() == "") {
   sender.set_text("");
  }
 }
-----------------------------

So, it appears that I'm getting it to work again using get_text(). But I don't know why get_value() stopped working (rather retained the value). And I'm not sure how the value gets cleared by set_text() = "".  But least for now it appears to be working, but we're still testing.

0
Nencho
Telerik team
answered on 21 Jan 2015, 08:55 AM
Hello Robert,

I am glad to see that the issue is overcame, however I am still unable to replicate it locally. This is why, if you face any further issues during the testing process, I would like to ask you to modify the provided sample, so we could reproduce the problem locally and suggest you the proper approach.

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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