Removing value by backspace in RadCombobox

12 posts, 0 answers
  1. Sanjay
    Sanjay avatar
    21 posts
    Member since:
    Nov 2010

    Posted 03 Feb 2011 Link to this post

    Hello,
    I have a load on demand radcombobox inside a Ajax panel.
    When the submitt button is clicked after making a selection and then removing the selection by backspace and confirming that the EmptyMessage of "Begin typing or select from list" is shown. The value when detected in the click event of the submit button is still showing the old selected value!!!!!

    Is there a special code I need to check? as the value must be a null string ("") when checked?

    rcbMaterial.SelectedValue =

     

    "" BUT rcbMaterial.Text.Trim = "Material Name" has old value.
    But since II am allowing User Text I cannot validate only selected value as it is always "" when User enters a  new value!

     

    I even went into the javascript with on blur but always got the sender._selectedItem and sender._selectedItem still having values after the physical box shows only the Emptymessage text.

    Note: the combo must also allow custom text.

    Please help,
    Sanjay

    <

     

     

    telerik:RadComboBox ID="rcbMaterial" runat="server" AllowCustomText="true" DropDownWidth="250px"

     

     

     

    EmptyMessage="Begin typing or select from list" EnableLoadOnDemand="true" EnableTextSelection="false"

     

     

     

    Height="200px" OnItemsRequested="rcbMaterials_ItemsRequested"

     

     

     

    SkinID="ddRegular" ToolTip="Begin typing or select from list" Width="200px" OnClientBlur="showMandatoryFields">

     

     

     

    </telerik:RadComboBox>

     

     

     

     

     

  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 09 Feb 2011 Link to this post

    Hello Sanjay,

    In general when you clear the text in the input of the combobox , selected value should be cleared as well.
    I've prepared a small example page using your declaration of the combobox , and it's working as expected.
    When you clear the text in the input , ItemRequested event is fired again , but since there is no text no items are added and thus the combobox has no item which is selected.
    If you continue to experience your problem please explain in details what is the exact scenario that you are trying to implement.

    All the best,
    Dimitar Terziev
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Sanjay
    Sanjay avatar
    21 posts
    Member since:
    Nov 2010

    Posted 11 Feb 2011 Link to this post

    Hi Dimitar ,
    Thanks for your help.
    The example you sent me has a little different feature in the combobox.
    First of all my combobox is in a Ajax panel and also my combobox is allowing to put a hint and filter it and show only the matching text contained anywhere inside the Item text values of combobox.
    I do not know if there is any tweaking required in it. Here is the code for Items Requested:

    rcbMaterials_ItemsRequested(

     

    ByVal sender As Object, ByVal e As

    RadComboBoxItemsRequestedEventArgs)

     

     

     

     

     

     

    Dim dtMaterialsRcb As New

    Data.DataTable()

     

     

    dtMaterialsRcb = SATS.Company.GetMaterials(CurrentUser.ConnectionString, CurrentUser.CompanyID, e.Text)

     

    sender.DataSource = dtMaterialsRcb

     

    sender.DataTextField =

     

     

     

    "MaterialName"

     

     

    sender.DataValueField =

     

    "ID"

     

     

    sender.DataBind()

     

     

    End

    Sub

     

     


    Here please note that the e.Text in the argument to populate the datatable is filtering inside my Query with %e.Text% and it works fine.

    But when we even remove the selected item the e.Text is = "" and the Query returns all the records. But I do not know why it still saves the
    last selected item after we remove it by backspace.

    I saw that I cannot attach a Mpeg file of 15 seconds to show how it is behaving for me while I am debugging.
    I may later send you the link of the Mpeg file while I am doing the debugging. But see if you can help me in my specific feature combobox


    I was trying to see your website today (Feb 14/2011) and just saw one load on demand example matching my scenario in your website:
    http://demos.telerik.com/aspnet-ajax/combobox/examples/loadondemand/automaticloadondemand/defaultvb.aspx

    Here is what I did and the combobox DOES NOT CLEAR the value by removing it by Backspace. Please try these steps:
    Enter a hint say 'da' in EntityDataSource combobox. You will see one filtered record with the name: 'Daniel Tonini'.
    Now select the name and remove it by pressing backspace and then tab out into the next field.
    You will see the value 'Daniel Tonini' stil sitting there.
    Can you please help as this is not the correct behaviour! There must be an option to De-Select the combobox item!!!


    Thanks
    Sanjay






  4. Yana
    Admin
    Yana avatar
    5039 posts

    Posted 17 Feb 2011 Link to this post

    Hello Sanjay,

    I tried to reproduce the issue in our online demos but to no avail. Could you please tell us the exact steps which we need to take in order to observe the prolem. The video also will be very useful.

    All the best,
    Yana
    the Telerik team
  5. Sanjay
    Sanjay avatar
    21 posts
    Member since:
    Nov 2010

    Posted 17 Feb 2011 Link to this post

    Hi Yana,

    Sorry but I have given you the Telerik demo URL and given you the exact steps.
    Here it is:

    This load on demand example is matching my scenario in your Demos website:
    http://demos.telerik.com/aspnet-ajax/combobox/examples/loadondemand/automaticloadondemand/defaultvb.aspx

    Here is what I did, and the combobox DOES NOT CLEAR the value by removing it by Backspace. Please try these steps:
    Enter a hint say 'da' in EntityDataSource combobox. You will see one filtered record with the name: 'Daniel Tonini'.
    Now select the name and remove it by pressing backspace and then tab out into the next field.
    You will see the value 'Daniel Tonini' stil sitting there.
    Can you please help as this is not the correct behaviour! There must be an option to De-Select the combobox item!!!


    Thanks
    Sanjay
  6. Charles
    Charles avatar
    4 posts
    Member since:
    Aug 2012

    Posted 19 Feb 2011 Link to this post

    Hello Sanjay,

    I am having the same problem as you, when the selected text is selected and backspace is pressed the selected text is cleared but returns there as soon as I TAB out.

    If I repeat the same procedure the second time the combo box selection is then cleared and the EmptyMessage value is shown.

    This problem was already mentioned in another thread:

    http://www.telerik.com/community/forums/aspnet-ajax/combobox/radcombobox-not-reloading-when-selection-is-cleared.aspx


    Any help would be appreciated.

    Thanks Charles
  7. Yana
    Admin
    Yana avatar
    5039 posts

    Posted 22 Feb 2011 Link to this post

    Hello,

    I was able to reproduce the issue thanks to the explanations in the forum post - it occurs in IE when the whole text is highlighted and cleared at once. Here is a simple work-around:

    - subscribe to OnCllientBlur event of the combobox and add the following javascript function to your page:

    <script type="text/javascript">
        function clientBlur(sender, args) {
            if (sender.get_text() == "") {
                sender.clearSelection();
                sender.get_items().clear();             
            }       
        }
    </script>

    Try it and let us know how it goes.

    Regards,
    Yana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  8. Charles
    Charles avatar
    4 posts
    Member since:
    Aug 2012

    Posted 22 Feb 2011 Link to this post

    Hi Yana,

    Thanks for the reply ... it worked fine.

    The only thing that I would need is that the selectedIndexChanged is called when the RadComboBox is cleared (i.e OnClientBlur) because I would need to clear some other controls when the RadComboBox is cleared. What should I include in the javascript function so that selectedIndexChanged is fired? 

    Thanks
    Charles
  9. Yana
    Admin
    Yana avatar
    5039 posts

    Posted 23 Feb 2011 Link to this post

    Hello Charles,

    I guess that you mean client SelectedIndexChanged event - if this is the case, why don't you just clear the other controls in OnClientBlur event handler?

    All the best,
    Yana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  10. Charles
    Charles avatar
    4 posts
    Member since:
    Aug 2012

    Posted 23 Feb 2011 Link to this post

    Hi Yana,

    In some instances I need the SelectedIndexChanged event to be fired because besides clearing other controls I have other logic in the event handler which cannot be handled via javascript.

    Thanks
    Charles
  11. Yana
    Admin
    Yana avatar
    5039 posts

    Posted 02 Mar 2011 Link to this post

    Hi Charles,

    I couldn't reproduce the issue when the combobox postbacks, please send us your exact scenario. Thanks

    All the best,
    Yana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  12. Charles
    Charles avatar
    4 posts
    Member since:
    Aug 2012

    Posted 02 Mar 2011 Link to this post

    When the radcombobox is cleared using the clientBlur fuction the combo box's SelectedIndexChanged event is not fired. I had to do the following javascript for it to fire:

     

     

    function clientBlur(sender, args) {
         if (sender.get_text() == "") {
             sender.clearSelection();
             __doPostBack(sender.get_id(), '{\"Command\" : \"Select\"}');
             //__doPostBack(sender.get_id(), "TextChange");
         }
     }

     

     

     

     

     

    Thanks and Regards
    Charles Mercieca

     

     

     

Back to Top