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

Backspace deleting last character typed

8 Answers 524 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 17 Sep 2008, 09:42 PM
If I have autocomplete turned on for a combobox and I press backspace while typing part of an item that auto-completes...this only clears the portion of the item that was automatically completed.  Instead, I want it to clear the last character I typed.

How would I go about this?

8 Answers, 1 is accepted

Sort by
0
Accepted
Rosi
Telerik team
answered on 18 Sep 2008, 12:26 PM
Hello Bob,

I suggest you set the EnableTextSelection property of RadComboBox to false.


Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bob
Top achievements
Rank 1
answered on 18 Sep 2008, 03:54 PM
Hmm...it's not behaving as I would expect.  While it's true that it's not highlighting it anymore, what I see now is that once it finds a match to my partial entry, it types the whole word out and moves the cursor to the end of the word.  I don't want that part to happen.

Is my only solution here to use JavaScript?  Or is the feature not functioning as it should?
0
Rosi
Telerik team
answered on 19 Sep 2008, 12:07 PM
Hello Bob,

Could you please provide us with more details on what is the desired behavior?

This behavior that you described is the behavior by design - the whole item will be displayed in the input box, the cursor will be at the end of the text. In this case when you hit backspace the last character will be deleted. Is not this the task that you are trying to achieve?


Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bob
Top achievements
Rank 1
answered on 19 Sep 2008, 12:58 PM
Using the default configuration of the RadComboBox, if a user types "SAM" and one of the items in the list is "SAMPLE", it will go ahead and auto-fill the word "SAMPLE", as well as highlight the portion of the word that was auto-filled.  So far, this is the default behavior.

Now, when a user presses the "BACKSPACE" key, I'd like for the entire portion of the highlighed word "PLE" as well as the last character they typed "M" to be deleted.  After that, the combo box can auto-fill again.  After the user presses "BACKSPACE" once in the above sample, the letters "SA" will be unhighlighted and "MPLE" will be highlighted.

Currently, if the user presses backspace "SAM" is unhighlighted and "PLE" remains highlighted.
0
Accepted
Simon
Telerik team
answered on 23 Sep 2008, 11:03 AM
Hi Bob,

You could handle the OnClientItemsRequesting and OnClientKeyPressing events as shown below:

        var queryText = ""
         
        function clientItemsRequesting(sender, eventArgs) 
        { 
            queryText = eventArgs.get_text(); 
        } 
         
        function clientKeyPressing(sender, eventArgs) 
        {             
            if (eventArgs.get_domEvent().keyCode == 8) 
            { 
                var newText = queryText.substring(0, queryText.length); 
 
                sender.set_text(unescape(newText)); 
            } 
        } 

This script will delete the last letter when the BACKSPACE is pressed and Items will be queried with the new text.

I hope this is what you are looking for.

Regards,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bob
Top achievements
Rank 1
answered on 23 Sep 2008, 05:32 PM
Perfect - thanks!
0
Jim
Top achievements
Rank 1
answered on 13 Oct 2008, 01:44 AM
What Bob requested should be the default behavior.
0
Simon
Telerik team
answered on 27 Oct 2008, 02:51 PM
Hello James,

Yes, this could be the default behavior.

We will consider integrating it in RadComboBox.

Thank you for your involvement in the matter.

Greetings,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Bob
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Bob
Top achievements
Rank 1
Simon
Telerik team
Jim
Top achievements
Rank 1
Share this question
or