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

Add name to search box

4 Answers 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
Danny asked on 19 Nov 2020, 05:24 PM

As I add an identifier to the input of the GRID search box, I need to manipulate that element, in this case I need to put the focus on the element.

 

@(Html.Kendo().Grid<MPaises>()
            .Name("rgvListado")
            .Columns(columns =>
            {
              columns.Bound(c => c.Codigo);
              columns.Bound(c => c.Nombre);
              columns.Bound(c => c.Continente);
            })
            .ToolBar(t => t.Search().Text("Buscar Pais"))
            .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
            .Sortable()
            .Groupable()
            .Selectable(selectable => selectable
              .Mode(GridSelectionMode.Single)
              .Type(GridSelectionType.Row))
            .DataSource(dataSource => dataSource
              .Ajax()
              .ServerOperation(false))
            )

 

best regards

4 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 23 Nov 2020, 01:30 PM

Hello Danny,

I would suggest you use the "k-grid-search" class for the selector in order to find the search input. Then, you could use the jQuery focus() method to focus the element. Below is an example:

$(".k-grid-search .k-input").focus() 

Here is a Dojo example where the described above is demonstrated. The same approach could be used in UI for ASP.NET MVC applications. 

I hope the provided information will be helpful. Let me know in case you have additional questions on the matter.

Regards,
Neli
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/.

0
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 23 Nov 2020, 03:47 PM
hello Neli.

correct that is the solution, but I necessarily need to assign an id, since the solution he proposes is for when there is a single grid on the screen, but in my case I have some grids, so the solution does not apply, in parameters when creating the Grid, How do I assign an id to the Input of the Search Box?
0
Neli
Telerik team
answered on 25 Nov 2020, 03:29 PM

Hello Danny,

You could use the id of the Grid to distinct the different search inputs. Below is an example where the id of the Grid is included in the selector:

$("#grid .k-grid-search .k-input").focus()

Here is an example of how you could add an id to the search input:

 $("#grid2 .k-grid-search .k-input").attr("id", "second-grid")

Or another option:

$($(".k-grid-search .k-input")[1]).attr("id", "second-grid")

In the Dojo example linked here, there are two Grids. I used the selectors described above to add some custom style, just for demonstration purposes, but the same selectors could be used for focusing the input.

Please take a look at the provided sample and let me know in case you have additional questions.

Regards,
Neli
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/.

0
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 25 Nov 2020, 10:24 PM
hello Neli.

Understood, I will apply the indicated, thank you very much.
Tags
Grid
Asked by
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Neli
Telerik team
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
Share this question
or