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

Tabbing not working

2 Answers 63 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Himanshu
Top achievements
Rank 1
Himanshu asked on 10 Mar 2014, 12:07 PM
Scenario:I have a RadCombobox and I have attached functions to most of the events. One event of the combobox is OnClientBlur and I am using this to check whether value in Combo is "Unassigned" or not. If it is "Unassigned" I need to cancel the onblur event and keep the focus on to the same combo.
Please refer screen shot 1.

This is the javascript which I has been used to cancel the event.
if (sender.get_text() === "Unassigned") {
eventArgs.get_domEvent().preventDefault();
return false;
}


Problem:When the user tabs out first time of the ComboBox the event gets cancelled and the focus stays on the same combo box (in this case it is the 3rd Combo).But when the user hits the tab button again the focus moves to the next control.When I debugged the code I found that when the user first hits the tab button, following line works
eventArgs.get_domEvent().preventDefault();

I can see the preventDefault function, see following snapshot. 
Please refer screen shot 2.

but when the user hits the tab button again I get an error and cannot see preventDefault function, see following snapshot
Please refer screen shot 3.

I am not able to understand what is going wrong here. Anyhelp would be appreciated.






2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Valyavicharski
Telerik team
answered on 13 Mar 2014, 09:41 AM
Hi Himanshu,

On OnClientBlur event is fired after the focus is lost. Why don't you try to return the focus of the combo instead cancel the event:

function OnClientBlur(sender, args) {
    var text = sender.get_text();
    if (text != "") {
        var input = sender.get_inputDomElement();
        setTimeout(function () {
            input.focus();
        }, 100);
    }
}

I hope this helps.

Regards,
Hristo Valyavicharski
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
0
Himanshu
Top achievements
Rank 1
answered on 04 Apr 2014, 08:31 AM
Thanks Hristo Valyavicharski.....
Tags
ComboBox
Asked by
Himanshu
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Himanshu
Top achievements
Rank 1
Share this question
or