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

Rad Grid Set Focus on row

5 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paolo
Top achievements
Rank 1
Paolo asked on 25 Sep 2014, 09:45 AM
I've a rad grid and I want to set the focus on a specified row of the grid using javascript.

I've done this function:


     function setActiveRow(p) {
         var grid = $find("<%=RadGridDati.ClientID%>");
         var masterTableView = grid.get_masterTableView();
         masterTableView.get_dataItems()[p].get_element().cells[0].focus();
     }

where p is the row number I want to set the focus.
It's running correctly with Explorer but not with Firefox and Crome.
Some ideas?

Thanks in advan ce

5 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 25 Sep 2014, 05:54 PM
Hi,

This method is a shortcut for .on( "focus", handler ) in the first and second variations, and .trigger( "focus" ) in the third.The focus event is sent to an element when it gains focus. This event is implicitly applicable to a limited set of elements, such as form elements (<input>, <select>, etc.) and links (<a href>). In recent browser versions, the event can be extended to include all element types by explicitly setting the element's tabindex property. An element can gain focus via keyboard commands, such as the Tab key, or by mouse clicks on the element.Elements with focus are usually highlighted in some way by the browser, for example with a dotted line surrounding the element. The focus is used to determine which element is the first to receive keyboard-related events.

for more detail please check : focus()

In short either you have to assign tabindex to column or you have to add text inside anchor tag. 

Let me know if you have any concern.

Thanks,
Jayesh Goyani
0
KTK
Top achievements
Rank 1
answered on 15 Nov 2016, 03:37 PM

Hi Jayesh,

I know this thread is a bit old but I have the same problem and I don't understand how to resolve this. Could you help me please.

 

Thanks,

Honza

0
Eyup
Telerik team
answered on 18 Nov 2016, 01:36 PM
Hello Honza,

If you are using the Batch editing mode:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

You can use the openCellForEdit method to achieve this requirement:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/client-side-api

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
0
KTK
Top achievements
Rank 1
answered on 25 Nov 2016, 09:46 AM

Hello Eyup,

thank you for tip but my problem is different. Here is my problem. I've got RadTextBox used as a filter for a datasource for RadGrid. And my task is when user use down arrow to allow him to move across rows in RadGrid and select part after enter is pressed. Everything works fine except of grid selecting. I am able to select first row with a script, keyboard navigation is allowed but user has to "activate" grid with click or with the tab pressing...

In IE it's working correctly but any other browser need to select my RadGrid.

 

Is there any way to get my page working as is required?

 

Thank you for any help

0
Eyup
Telerik team
answered on 30 Nov 2016, 06:27 AM
Hi Honza,

You can get the grid element using script logic when the page is loaded and call the focus() method. Alternatively, you can hint your user to use some kind of focusing key combination, for example Ctrl+Y:
http://demos.telerik.com/aspnet-ajax/grid/examples/accessibility-and-internationalization/keyboard-support/defaultcs.aspx

Regards,
Eyup
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Paolo
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
KTK
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or