Use arrow keys to navigate through RadGrid Textboxes

2 posts, 0 answers
  1. Francois
    Francois avatar
    1 posts
    Member since:
    Apr 2014

    Posted 04 Apr 2014 Link to this post

    Hi All, 

    Just a quick post to share a useful trick with you. 

    I just spent few hours looking for an easy way to navigate through textboxes embeded in a Radgrid using the arrow keys. 
    [URL=https://imageshack.com/i/2hdgqop][IMG]http://imagizer.imageshack.us/v2/xq90/89/dgqo.png[/IMG][/URL]

    I found the solution below but putting this in place takes a while and it's a bit to complicated for the lazy guy I am  : 
    http://www.telerik.com/support/code-library/excel-look-and-feel-for-radgrid

    But I finally found a really easy way of doing this (setup in 1 min) using jQuery, you just need to copy/past the code below in your aspx, and it works perfectly : (IE and Chrome)

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script>
    $(document).ready(function(){
     $('input').keyup(function(e){
      if(e.which==39)
       $(this).closest('td').next().find('input').focus();
      else if(e.which==37)
       $(this).closest('td').prev().find('input').focus();
      else if(e.which==40)
       $(this).closest('tr').next().find('td:eq('+$(this).closest('td').index()+')').find('input').focus();
      else if(e.which==38)
       $(this).closest('tr').prev().find('td:eq('+$(this).closest('td').index()+')').find('input').focus();
     });
    });
    </script>

    I'm not saying that's the most efficient way of doing it, but it's quick and easy :)
    You can find more information here : http://www.knowlbase.in/2012/01/traverse-cursor-through-text-box-with.html?showComment=1396585935631#c5873482477892910721

    Cheers !
  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 09 Apr 2014 Link to this post

    Hello Francois,

    Thank you for sharing knowledge with the Telerik community. Such actions are highly appreciated and as a token of gratitude I am updating your Telerik points.

    Regards,
    Pavlina
    Telerik
     
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
     
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.