Copy/Paste into RadComboBox

9 posts, 0 answers
  1. Toby
    Toby avatar
    59 posts
    Member since:
    Jul 2009

    Posted 08 Mar 2011 Link to this post

    Hi,
     
    If a user types into the combobox normally it works fine, but it you copy/paste text into the combo box it does pick up the values on post back.

    Is this a know issue?

    I tried this fix

     
    var $ = $telerik.$;
     
    var $T = Telerik.Web.UI;
     
    var $p = Telerik.Web.UI.RadComboBox.prototype;
     
    var onPaste = $p._onPaste;
     
    $p._onPaste = function (e) {
     
    text = this.get_text();
     
    this._updateFilterText = true;
     
    };

    and it fires properly but the value of this.get_text(); is empty if data has been pasted in there.

    this is similar to http://www.telerik.com/community/forums/aspnet-mvc/combobox/autocomplete-copy-and-paste-not-working-in-ie.aspx#1554552

    thanks
    Toby
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 11 Mar 2011 Link to this post

    Hi Toby,

    Thanks for your interest.

    I tried the scenario that you describe and AutoComplete does not work when I paste text using right click of the mouse. It does work however, when I use Ctrl+V. Unfortunately I can not give you an answer now, because we will need more time to investigate the issue. I will write you back as soon as we figure out why this is happening.   

    Greetings,
    Kate
    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!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 18 Mar 2011 Link to this post

    Hi Toby,

    While revisiting the case we were able to observe different behaviors that were inconsistent with your description of the issue. In order to start working on it we will need to reproduce it consistently. Can you paste here the definition of the RadComboBox with which you observed the issue as well as specify in which browsers you observed it?

    Regards,
    Simon
    the Telerik team
  5. Barbara
    Barbara avatar
    3 posts
    Member since:
    Sep 2010

    Posted 18 Mar 2013 Link to this post

    Have there been any updates on this?

    We are experiencing this issue where we have a RadComboBox and a required field validator on the page. Ctrl-V works and triggers the validation but right-click and paste does not.
    Thanks,
  6. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 19 Mar 2013 Link to this post

    Hi Barbara,

    Current build 2013.1.220 supports right-click and paste with latest versions for all browsers except IE. For older versions and IE try to add the following javascript:
    function pageLoad() {
        var combo = $find('RadComboBox1');
     
        $('#RadComboBox1_Input').live('input paste', function(e) {
            //Get pasted value
            var pastedValue = $(this).val();
            //Request items
            combo.requestItems(pastedValue, false);
        });
    }
    This code attaches event listener for OnInput and OnPaste events of the combo's input element and force combo to request items.

    Regards,
    Hristo Valyavicharski
    the Telerik team
    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.
  7. Daniel
    Daniel avatar
    1 posts
    Member since:
    Jul 2011

    Posted 08 May 2013 Link to this post

    Hello,

    I had the same problem in one of my projects and fixed it that way:

    I first set the EnableAutmoaticLoadOnDemand-property to false.
    <telerik:RadComboBox ID="ComboBox1" runat="server" AllowCustomText="false" Filter="Contains"
    MarkFirstMatch="true" ShowToggleImage="false" OpenDropDownOnLoad="false"
    OnItemsRequested="ComboBox1_ItemsRequested" EnableAutomaticLoadOnDemand="false"
    OnKeyUp="ComboBox1_KeyUp()">
    </telerik:RadComboBox>

    Than I implemented a javascriptfunction at the OnKeyUp-event that fires the requestItems-method.
    function ComboBox1_KeyUp() {
        var combo = $find("<%=ComboBox1.ClientID %>");
        var comboText = combo.get_text();
        combo.requestItems(comboText, false);
    }

    With this fix there's only one event that triggers the requestItems-method.

    The problem pasting from clipboard with right-click isn't affected by that fix.

    I think that the problem occurs because the internal function, that is enabled by the EnableAutmoaticLoadOnDemand-property, uses the OnTextChanged-event. This event won't be fired when data is pasted or the delete key is pressed for example.

    Regards
    Daniel
  8. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 13 May 2013 Link to this post

    Hi Daniel,

    At the moment you set AllowCustomText to false and  Filter equal to Contains which are mutually exclusive.
    This issue is resolved and the fix will be included in the upcoming service release. Until the fix release you could try to use the following workaround:
    <script type="text/javascript">
        function ComboBox1_KeyUp() {
            var combo = $find("<%=RadComboBox1.ClientID %>");
            var comboText = combo.get_text();
            combo.requestItems(comboText, false);
        }
        function OnClientBlur(sender, args) {
            var comboText = sender.get_text();
            sender.requestItems(comboText, false);
        }
    </script>

    <telerik:RadComboBox ID="RadComboBox1" runat="server" AllowCustomText="false" Filter="Contains"
                MarkFirstMatch="true" ShowToggleImage="false" OpenDropDownOnLoad="false" OnClientBlur="OnClientBlur"
                OnItemsRequested="RadComboBox1_ItemsRequested" EnableAutomaticLoadOnDemand="false"
                OnKeyUp="ComboBox1_KeyUp()">
            </telerik:RadComboBox>

    Kind regards,
    Hristo Valyavicharski
    the Telerik team
    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.
  9. Richard
    Richard avatar
    63 posts
    Member since:
    Apr 2008

    Posted 08 Aug 2013 Link to this post

    Our page has 10 controls.  I wrote a simple foreach loop to iterate through the controls (comboValue0 - comboValue9).  I am getting "Object not found" when I try to run your code specified.

    This is the line that is failing.
    $('#ctl00_ContentPlaceHolder2_RadPanelBar1_i0_SearchControl1_comboValue' + i + '_Input').live

     Any help would be appreciated.

    function pageLoad() {
        for (var i = 0; i <= 9; i++) {
     
            debugger;
            var combo = $find('ctl00_ContentPlaceHolder2_RadPanelBar1_i0_SearchControl1_comboValue' + i);
     
            $('#ctl00_ContentPlaceHolder2_RadPanelBar1_i0_SearchControl1_comboValue' + i + '_Input').live('input paste', function (e) {
                //Get pasted value
                var pastedValue = $(this).val();
                //Request items
                combo.requestItems(pastedValue, false);
            });
        }
  10. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 13 Aug 2013 Link to this post

    Hi Richard,

    jQuery live() was deprecated. Try to replace your code with the following:
    Copy Code
    function pageLoad() {
         $('.rcbInput, .radPreventDecorate').bind('input paste', function () {
            var comboInput = $(this);
            setTimeout(function () {
                console.log(comboInput.parents('div:eq(0)').attr('id'));
                combo = $find(comboInput.parents('div:eq(0)').attr('id'));
                console.log(combo._inputDomElement.value);
                combo.requestItems(combo._inputDomElement.value, false);
            }, 1);
        });
    }

    it should be applied for all combos.


    Regards,
    Hristo Valyavicharski
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017