Focus RadGrid in a RadWindow with KeyBoard Navigation

2 posts, 1 answers
  1. loowool
    loowool avatar
    60 posts
    Member since:
    Sep 2006

    Posted 21 Feb 2011 Link to this post

    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



  2. Answer
    Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 25 Feb 2011 Link to this post

    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!
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top