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

Select Text After Request Items

3 Answers 90 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 08 Mar 2010, 07:07 PM
I am using the RadCombobox with the Load On Demand functionality.  I have JS code that selects all the text in the combobox when a user clicks on it (This should be a feature of the combobox I think).  This works once the combobox has had the data loaded into it but not the first time when the LOD is called.  Right now I have it linked to the OnClientFocus event.  I have tried linking the same code to the OnClientItemsRequested event but it doesn't work.  Any thoughts?  Below is my JS code.

function OnClientFocus(sender) {
var combo = document.getElementById(sender._uniqueId);
combo.select();

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 10 Mar 2010, 07:22 PM
Hi Dave,

Your code finds the outermost DIV element representing the RadComboBox and a select method on it.

On the other hand RadComboBox has the selectText method which accepts two parameters - startIndex  and endIndex. The method selects endIndex characters starting from startIndex inclusive.

You use this method to select the text in the RadComboBox, i.e.

sender.selectText(0, sender.get_text().length);

Is this what you are looking for?

Sincerely yours,
Simon
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dave
Top achievements
Rank 1
answered on 23 Mar 2010, 05:41 PM
I tired putting that code in the OnClientItemsRequested client side event but it does not seem to change the behavior.  What it appears to do is select the text, then after the LOD functionality has finished Loading items it moves the cursor to the end of the text.  Any way to not have it reset the cursor position at the end of loading items?
0
Veselin Vasilev
Telerik team
answered on 26 Mar 2010, 10:18 AM
Hi Dave,

It is working ok on our side - please find attached a sample page.
You can try using the setTimeout function:

setTimeout(function() { sender.selectText(0, sender.get_text().length);}, 100);

Best wishes,
Veskoni
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
Dave
Top achievements
Rank 1
Answers by
Simon
Telerik team
Dave
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or