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

Copy/Paste into RadComboBox

8 Answers 238 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Toby
Top achievements
Rank 1
Toby asked on 08 Mar 2011, 06:03 PM
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

8 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 11 Mar 2011, 02:44 PM
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!
0
Simon
Telerik team
answered on 18 Mar 2011, 04:06 PM
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
0
Barbara
Top achievements
Rank 1
answered on 18 Mar 2013, 09:19 PM
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,
0
Hristo Valyavicharski
Telerik team
answered on 19 Mar 2013, 04:27 PM
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.
0
Daniel
Top achievements
Rank 1
answered on 08 May 2013, 10:51 AM
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
0
Hristo Valyavicharski
Telerik team
answered on 13 May 2013, 10:16 AM
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.
0
Richard
Top achievements
Rank 2
answered on 08 Aug 2013, 04:05 PM
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);
        });
    }
0
Hristo Valyavicharski
Telerik team
answered on 13 Aug 2013, 01:43 PM
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.
Tags
ComboBox
Asked by
Toby
Top achievements
Rank 1
Answers by
Kate
Telerik team
Simon
Telerik team
Barbara
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Daniel
Top achievements
Rank 1
Richard
Top achievements
Rank 2
Share this question
or