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

Lost focus on RadComboBox after change selected index

4 Answers 260 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Leonid Caceres
Top achievements
Rank 1
Leonid Caceres asked on 11 May 2015, 09:01 PM

Hi, I'm developing an application and I can't lost the focus on a radcombobox after select an item in the Radcombobox to focus in other control (this example a textbox) by client javascript/jquery code. But in the image attached it seems the focus on both controls. I only want the focus on the textbox.

My code:

<rad:RadComboBox ID="cmbRegDep" Skin="MetroTouch" EnableEmbeddedSkins="true"   ShowDropDownOnTextboxClick="true" MarkFirstMatch="true"
runat="server" Height="400px" Width="100%" DataValueField="depNo" DataTextField="depNo" EmptyMessage="Velg"  OnClientSelectedIndexChanged="onSelectedIndexChanging_cmbDep" 
HighlightTemplatedItems="true" DropDownWidth="300px" OffsetX="0" Filter="Contains"  >
<HeaderTemplate>
<ul>
<li class="col1H">Nr.</li>
<li class="col2H">Beskrivelse</li>
</ul>
</HeaderTemplate>
<ItemTemplate>
<ul>
<li class="col1"><%# DataBinder.Eval(Container.DataItem, "depNo") %></li>
<li class="col2"><%# DataBinder.Eval(Container.DataItem, "depName") %></li>
</ul>
</ItemTemplate>
</rad:RadComboBox>

    <asp:TextBox ID="txtDep" runat="server"></asp:TextBox>

<script type="text/javascript">

    function onSelectedIndexChanging_cmbDep(sender, eventArgs) {
        document.getElementById('<%= txtDep.ClientID%>').focus();

    }
</script>

4 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 14 May 2015, 12:40 PM
Hi Leonid,

Combo has a collapse animation. Try to put small timeout to wait until it finishes:

function onSelectedIndexChanging_cmbDep(sender, eventArgs) {
    setTimeout(function () {
        document.getElementById('<%= txtDep.ClientID%>').focus();
    }, 100);
}

Regards,
Hristo Valyavicharski
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Leonid Caceres
Top achievements
Rank 1
answered on 19 May 2015, 01:26 PM
I've tried with this solution but it's still remaining a class style rcbFocused on the Radcombobox that only dissapear when I click with the mouse in other part of the page. An also the event (OnClientSelectedIndexChanged,OnClientSelectedIndexChanging) seems finish in that moment. Is there a way to change the focus in other control without leave something pending in the RadCombobox?
0
Hristo Valyavicharski
Telerik team
answered on 20 May 2015, 12:36 PM
You can remove this css class with jquery:

function onSelectedIndexChanging_cmbDep(sender, args) {
                $telerik.$(sender.get_element()).find('table').removeClass('rcbFocused');
                setTimeout(function () {
                    document.getElementById('<%= txtDep.ClientID%>').focus();
                }, 100);
            }


Regards,
Hristo Valyavicharski
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Leonid Caceres
Top achievements
Rank 1
answered on 21 May 2015, 02:40 PM
Thank you for show me how remove the css in the Radcombobox
Tags
ComboBox
Asked by
Leonid Caceres
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Leonid Caceres
Top achievements
Rank 1
Share this question
or