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

RadComboBox SelectText Question

1 Answer 138 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
shunman
Top achievements
Rank 1
shunman asked on 29 Jan 2013, 06:55 AM
Hello Telerik.

I have a question RadCoboBox's "SelectText" function.

It can select part of text through selected length.

I tried use this function but it doesn't work.

So i have tried many test, finally getting result.

If i want to use SeelectText function , i should to set some properpties.

EnableTextSelection="true" EnableLoadOnDemand="true".

that properies are set true, selectText was worked.

Is it bug or planned scenario?

I attached sample code please check this.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
 
            function RadComboBox1_Focus(sender, args) {
                sender.selectText(0, 2);
            };
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <div>
 
            <telerik:RadTextBox runat="server" ID="TextBox1" TabIndex="1">
            </telerik:RadTextBox>
            <div style="height:30px;"></div>
            <telerik:RadComboBox ID="RadComboBoxLookupFirm" runat="server" Width="350" EnableTextSelection="false" TabIndex="2" OnClientFocus="RadComboBox1_Focus">
                <Items>
                    <telerik:RadComboBoxItem Text="1111111" Selected="true" />
                    <telerik:RadComboBoxItem Text="2222222" />
                    <telerik:RadComboBoxItem Text="3333333" />
                    <telerik:RadComboBoxItem Text="4444444" />
                </Items>
            </telerik:RadComboBox>
            <div style="height:30px;"></div>
            <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="350" EnableTextSelection="true" EnableLoadOnDemand="true"  TabIndex="3" OnClientFocus="RadComboBox1_Focus">
                <Items>
                    <telerik:RadComboBoxItem Text="1111111" Selected="true" />
                    <telerik:RadComboBoxItem Text="2222222" />
                    <telerik:RadComboBoxItem Text="3333333" />
                    <telerik:RadComboBoxItem Text="4444444" />
                </Items>
            </telerik:RadComboBox>
        </div>
    </form>
</body>
</html>

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 06 Feb 2013, 04:28 PM
Hi Shunman,

Try to call this in RadComboBox1_DropDownOpened event:

function RadComboBox1_DropDownOpened(sender,args)
{
    sender.selectText(0, 2);
}
<telerik:RadComboBox ID="RadComboBox1" runat="server" Width="350" EnableTextSelection="true" EnableLoadOnDemand="true" TabIndex="3" OnClientFocus="RadComboBox1_Focus" OnClientDropDownOpened="RadComboBox1_DropDownOpened">
    <Items>
        <telerik:RadComboBoxItem Text="1111111" Selected="false" />
        <telerik:RadComboBoxItem Text="2222222" />
        <telerik:RadComboBoxItem Text="3333333" />
        <telerik:RadComboBoxItem Text="4444444" />
    </Items>
</telerik:RadComboBox>

because at the moment there are other events which are fired immediately after you focus the combo.

I hope this helps.

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.
Tags
ComboBox
Asked by
shunman
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or