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

Setting focus in datasource change event

1 Answer 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 16 Mar 2013, 09:09 PM
Below is the definition for my datasource object.  In the change event, I am setting focus based on whether or not the datasource contains any items.  Focusing on the dropdownlist ("custom1combo") is working, however the part where focus is set on "portraitNotes", which is a text area, is not working.

This is the line in question:
$("#portraitNotes").focus();

The weird thing is it works fine in other areas of my site, just not here.


custom1DataSource = new kendo.data.DataSource({
    serverFiltering: true,
    transport: {
        read: {
            url: "wsRest.svc/custom1/",
            data: {
                user: function () {
                    return userField.value;
                },
                client: function () {
                    return $("#clientCombo").val();
                },
                matter: function () {
                    return $("#matterCombo").val();
                }
            }
        }
    },
    change: function () {
        //when data is updated, if there is more than 1 item we need to enable the menu
        var custom1 = $("#custom1Combo").data("kendoDropDownList");
        custom1.enable(false);
         
        if (custom1DataSource.data().length > 1) {
            custom1.enable(true);
    $("#custom1Combo").focus();         
        }
    else {
                            $("#portraitNotes").focus();
        }
    }
});




1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 19 Mar 2013, 10:01 AM
Hello Kjell,

Since we not sure what exactly is the case from the code you shared, I would suggest you to create a jsbin example where we can see the problem and search for a solution.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Kjell
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or