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

focus on the grid search bar

3 Answers 292 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Klayton
Top achievements
Rank 1
Veteran
Klayton asked on 08 Apr 2021, 02:50 PM
Hi, Is it possible to set the keyboard input focus on the grid search bar as soon as I load the entire page? Thanks.

3 Answers, 1 is accepted

Sort by
1
Marin Bratanov
Telerik team
answered on 08 Apr 2021, 04:58 PM

Hi Klayton,

You can focus it with plain JS, if you add a function similar to this one, you can call it in OnAfterRenderAsync by passing a correct selector:

    function focusElement(selector) {
        var elem = document.querySelector(selector);
        if (elem && elem.focus) {
            setTimeout(function () {
                elem.focus();
            }, 30);
        }
    }

Regards,
Marin Bratanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Klayton
Top achievements
Rank 1
Veteran
answered on 08 Apr 2021, 08:53 PM
Sorry for my ignorance. But if I have three grids on a page, how do I reference which grid search bar I want to focus on? Thanks
0
Marin Bratanov
Telerik team
answered on 09 Apr 2021, 07:01 AM

Hello Klayton,

You can use any approach you like - n-th of type selectors, a Class on the individual grid to cascade through, or other identifiers in your structure that you can cascade selectors through. It is entirely up to your project logic to decide how to get the reference to the thing you want to alter.

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Klayton
Top achievements
Rank 1
Veteran
Answers by
Marin Bratanov
Telerik team
Klayton
Top achievements
Rank 1
Veteran
Share this question
or