1 Reply Latest reply on May 10, 2012 1:28 PM by paul.dijou

    Apply rich:hotkey on rich:datatable?

    syanegal

      Hi,

      I am trying to apply up, down hotkey on rich:datatable and am wondering how can I achieve this. When I am in a input text box and press down arrow key my goal is to navigate to the next row's input text box field. But I am not sure how to get the handle of the current row(rowId?) dynamically. Please help me with a sample code or point me to right direction.

      Thanks!

        • 1. Re: Apply rich:hotkey on rich:datatable?
          paul.dijou

          What about something like:

           

          <rich:hotKey selector=".aCSSclass" key="down" onkeyup="jQuery(this).parent('tr').next().find('.aCSSclass').focus()" />
          

           

          And adding "styleClass="aCSSclass"" to your inputs (you can change the name of the CSS class of course).

           

          The idea is to bind the hotKey to all your input with "selector=".aCSSclass"", and each time the "down" key is pressed, you start from you input with "jQuery(this)", go top to the row with "parent('tr')", go to the next row with "next()", then go down to the correct input in this row with "find('.aCSSclass')" and put the focus on it with "focus()".

           

          Replace "down" with "up" and "next()" with "prev()" for the other key.

           

          I'm not a jQuery expert, so I can have make a mistake on my syntax, but you got the main idea.

           

          Regards,