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

Focus RadGrid in a RadWindow with KeyBoard Navigation

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
loowool
Top achievements
Rank 2
loowool asked on 21 Feb 2011, 04:24 PM
Dear Telerik,

We have a RadTree that when you click any of its nodes, it opens a RadWindow containing a new dynamic page with a RadGrid, and RadToolbar. In the code behind, we're setting the:
 
radGrid.ClientSettings.ClientEvents.OnGridCreated = "GridCreated";

And in javascript we're setting focus to the grid:
function GridCreated(sender, args) {
     var currentGrid = $find(sender.ClientID);

      var row = currentGrid.get_masterTableView().get_selectedItems()[0];

 

 

      if (row)

 

            currentGrid.set_activeRow(row.get_element());

 

  currentGrid.Control.focus();
}

When you click any tree node, it hides any open window, then tries to locate the corresponding window to show:
1) If no window is found then it opens a new window populating it with a grid, and setting focus to the grid's first row correctly, and we can navigate using the keyboard.
2) If a window is found then it only shows that window, but the grid is losing focus, and we can't use keyboard navigation unless we click on the grid to activate it.

Is there any way to set focus to the grid in the second case above?

We tried to call the currentGrid.Control.focus(); but with no luck, we tried also

currentGrid.get_masterTableView().get_dataItems()[0].get_element().cells[0].focus();

and we could not make the grid to receive focus and we can't navigate using the keyboard.

Can you please help?

Salah A. Malaeb
TeknoBuild



1 Answer, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 25 Feb 2011, 09:10 AM
Hi loowool,

To achieve the desired functionality you could try focusing the RadGrid manually:
Into the content page you could add function which get the grid and focus it:
function focusRadGrid()
{
       var grid = $get("<%= RadGrid1.ClientID %>");
       grid.focus();
}

Then on the main page you could call this function with the following code snippet:
function focusGrid()
{
      var oWin = $find("<%=RadWindow1.ClientID %>");
      oWin.get_contentFrame().contentWindow.focusRadGrid();
}

Additionally I am sending you a simple example which demonstrates the desired functionality.
I hope this helps.

Kind regards,
Radoslav
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
loowool
Top achievements
Rank 2
Answers by
Radoslav
Telerik team
Share this question
or