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

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

    Posted 13 Jan 2015 Link to this post


    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




  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 16 Jan 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Robert Helm
    Robert Helm avatar
    54 posts
    Member since:
    Feb 2009

    Posted 16 Jan 2015 in reply to Nencho Link to this post

    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.

  5. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 21 Jan 2015 Link to this post

    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.

     
Back to Top