Need to determine Tab Key vs Enter Key in EditStopped

Posted by: scat on 8 September 2017, 2:54 pm EST

  • Posted 8 September 2017, 2:54 pm EST

    I need to advance to the next row\same column when the enter key is used but advance to the next column\same row when the tab key is used.  The following code handles advancing to the next row\same column when the enter key is used but advances to the next column\2nd row when the tab key is used.  Without this code, the enter key doesn't advance anywhere it just stays in the same cell.  I have tried using the keyCode but it always evaluates to 0.


    if (spread.ActiveRow < spread.GetRowCount())


    {


    spread.MoveToNextRow();


    }


    Any tips area greatly appreciated!

  • Replied 8 September 2017, 2:54 pm EST

    I'm not sure whether you are asking in regard to the winforms product or the asp product.

    In the case of the winforms product you can find instructions on how to do that in the installed help file. If you will go to the Contents pane of the help and open the Developer's Guide tree, you will find a Managing Keyboard Interaction subtree, expanding that you will find a page called Changing the Default Keyboard Map. It has sample code demonstrating how.

    If you are working with the asp control then it is done client-side with the AddKeyMap and RemoveKeyMap scripting methods. You can find information about those and some sample code snippets in the installed help file if you will go to the Contents pane then expand the Client-Side Scripting Reference subtree then expand Scripting Members followed by Methods to find pages with this information.

  • Replied 8 September 2017, 2:54 pm EST

    Thank you for getting back to me.  Unfortunately, we tried using the AddKeyMap and I am still getting the same results.  This is using an ASP Control with the EditStopped event.  The KeyCode seems to be coming through as "Undefined" when using either Enter or Tab.  Below is the entire function.


    function FpSpread1_EditStopped(event){


    //Add code to handle your event here.


    var spread = document.getElementById("ctl00_phMain_pcBid_FpSpread1");


     


    if (spread.ActiveRow != null)


    {


    //show that the price has been updated


    spread.SetValue(spread.ActiveRow , 0, "*" , false);


     


    //automatically put cursor on next row so that they can quickly just enter price enter price enter price


    if (spread.ActiveRow < spread.GetRowCount())


    {


    spread.AddKeyMap(13, true, true, false, spread.MoveToNextRow());


    }


    }

  • Replied 8 September 2017, 2:54 pm EST

    Hello,

    I used the code as follows on window.onload () and it seems to be working fine.

     
     function window.onload()

       {          

            var ss = document.getElementById("FpSpread1");

            ss.AddKeyMap(13, false, false, false, "this.MoveToNextRow()");

            ss.AddKeyMap(9, false, false, false, "this.MoveToNextCell()");     

        }

    Let me know if you face any issues implementing the same.

     

    Thanks,

     

     

  • Replied 8 September 2017, 2:54 pm EST

    Thank you Deepak, this worked great for me with out the using the code for the tab key (commented out ss.AddKeyMap(9,false, false, false,.....).  I did notice though that my cursor is showing in the incorrect location.  As an example, the cursor shows in row 4, column 9 but is actually in row 5, column 9.  Is there something that I can do to have the cursor appear in the cell where it is currently positioned?
  • Replied 8 September 2017, 2:54 pm EST

    Scat,

    I am not able to comprehend the issue here. Do you see the cursor appearing in the cell which has lost focus (previous)? If this is correct , you may need to call spread's EndEdit ( ) method to make the editing cursor disappear.

     

    Thanks,

  • Replied 8 September 2017, 2:54 pm EST

    Thank you!  That worked like a charm.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels