﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - http://www.intersoftpt.com/Community/WebGrid/the-grid-using-Left-and-Right-Arrow-Keys/</title><link>http://www.intersoftsolutions.com/Community/WebGrid/httpwwwintersoftptcomCommunityWebGridthe-grid-using-Left-and-Right-Arrow-Keys/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>http://www.intersoftpt.com/Community/WebGrid/the-grid-using-Left-and-Right-Arrow-Keys/</title><link>http://www.intersoftsolutions.com/Community/WebGrid/httpwwwintersoftptcomCommunityWebGridthe-grid-using-Left-and-Right-Arrow-Keys/</link><pubDate>Sun, 20 Jul 2014 22:18:19 GMT</pubDate><dc:creator>Hans</dc:creator><category>webgrid allow left right key</category><description>&lt;p&gt;Hello,&lt;br&gt;&lt;br&gt;I’m glad to hear that the JavaScript code suitable for your current scenario.&lt;br&gt;&lt;br&gt;Should you have further question, please do not hesitate to contact us.&lt;br&gt;&lt;br&gt;Thank you.&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Hans K.&lt;br&gt;&lt;/p&gt;</description></item><item><title>http://www.intersoftpt.com/Community/WebGrid/the-grid-using-Left-and-Right-Arrow-Keys/</title><link>http://www.intersoftsolutions.com/Community/WebGrid/httpwwwintersoftptcomCommunityWebGridthe-grid-using-Left-and-Right-Arrow-Keys/</link><pubDate>Thu, 17 Jul 2014 22:13:49 GMT</pubDate><dc:creator>BennySun</dc:creator><category>webgrid allow left right key</category><description>Hello,
Thanks for you reply.

It's OK.

Thanks again.

</description></item><item><title>http://www.intersoftpt.com/Community/WebGrid/the-grid-using-Left-and-Right-Arrow-Keys/</title><link>http://www.intersoftsolutions.com/Community/WebGrid/httpwwwintersoftptcomCommunityWebGridthe-grid-using-Left-and-Right-Arrow-Keys/</link><pubDate>Thu, 17 Jul 2014 00:20:42 GMT</pubDate><dc:creator>Hans</dc:creator><category>webgrid allow left right key</category><description>&lt;p&gt;Hello,&lt;br&gt;&lt;br&gt;Please forgive me for lack of understanding about the reported problem.&lt;br&gt;&lt;br&gt;I modified the JavaScript code by adding code to handle Left and Right key event.&lt;br&gt;&lt;br&gt;I add a new function that suitable with Left and Right key event:&lt;br&gt;&lt;/p&gt;&lt;pre&gt;function activateEditModeColumn(grid, curCellIndex, nextCellIndex, curRowIndex){
    if (nextCellIndex &amp;gt;= 0 &amp;amp;&amp;amp; nextCellIndex &amp;lt; grid.RootTable.Columns.length)
    {
        var curRowEl = grid.RootTable.GetRow(curRowIndex);
        var currCell = curRowEl.GetCell(curCellIndex);
        var nextCell = curRowEl.GetCell(nextCellIndex);
        grid.SetFocus();
        currCell.Select(true);
        curRowEl.Select();
        nextCell.ActivateEdit();
    }
}&lt;/pre&gt;&lt;p&gt;I add a couple of line codes in WebGrid1_OnEditKeyDown function:&lt;br&gt;&lt;/p&gt;&lt;pre&gt;//if left arrow key
else if (event.keyCode == 37) {
    grid.ExitEdit(1, 0, 0); 

    intervalObj = setInterval(function ()
    {
        if (!grid.IsInProgress)
        {
            activateEditModeColumn(grid, curCell - 1, curCell - 2, curRowIndex);
            clearInterval(intervalObj);
            intervalObj = null;
        }
    }, 5);
}

//if right arrow key
else if (event.keyCode == 39) {
    grid.ExitEdit(1, 0, 0); 

    intervalObj = setInterval(function ()
    {
        if (!grid.IsInProgress)
        {
            activateEditModeColumn(grid, curCell - 1, curCell, curRowIndex);
            clearInterval(intervalObj);
            intervalObj = null;
        }
    }, 5);
}&lt;/pre&gt;&lt;p&gt;I attached the modified page as well. Please kindly have review on the page once again.&lt;br&gt;&lt;br&gt;Thank you.&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Hans K.&lt;br&gt;&lt;/p&gt;</description></item><item><title>http://www.intersoftpt.com/Community/WebGrid/the-grid-using-Left-and-Right-Arrow-Keys/</title><link>http://www.intersoftsolutions.com/Community/WebGrid/httpwwwintersoftptcomCommunityWebGridthe-grid-using-Left-and-Right-Arrow-Keys/</link><pubDate>Wed, 16 Jul 2014 02:33:36 GMT</pubDate><dc:creator>BennySun</dc:creator><category>webgrid allow left right key</category><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;thanks for your help,&amp;nbsp;But I need the support of left and right key, how to write js code yet.&lt;/p&gt;</description></item><item><title>http://www.intersoftpt.com/Community/WebGrid/the-grid-using-Left-and-Right-Arrow-Keys/</title><link>http://www.intersoftsolutions.com/Community/WebGrid/httpwwwintersoftptcomCommunityWebGridthe-grid-using-Left-and-Right-Arrow-Keys/</link><pubDate>Wed, 16 Jul 2014 00:58:43 GMT</pubDate><dc:creator>Hans</dc:creator><category>webgrid allow left right key</category><description>Hello,&lt;br&gt;&lt;br&gt;I made a WebGrid page that perhaps similar with your current scenario.&lt;br&gt;&lt;br&gt;I add JavaScript code that handle Key Up and Key Down event while in edit mode in WebGrid.&lt;br&gt;&lt;br&gt;If we press Key Up/Down while in editing mode, the cursor will be focus on the next/previous row.&lt;br&gt;&lt;br&gt;Here’s the JavaScript code:&lt;pre&gt;var intervalObj;
function activateEditMode(grid, curRowIndex, nextRowIndex, columnName, cell) {
    if (nextRowIndex &amp;gt;= 0 &amp;amp;&amp;amp; nextRowIndex &amp;lt; grid.TotalRows) {
        var nextRowEl = grid.RootTable.GetRow(nextRowIndex);
        var curRowEl = grid.RootTable.GetRow(curRowIndex);
        var cell1 = nextRowEl.GetCell(cell);
        var cell2 = curRowEl.GetCell(cell);
        grid.SetFocus();
        cell2.Select(true);
        nextRowEl.Select();
        cell1.ActivateEdit();
    }
}

function WebGrid1_OnEditKeyDown(controlId, keyCode)
{
    // get the grid
    var grid = ISGetObject(controlId);
    // get current information about row and cell
    var activeEditCell = grid.GetActiveEditCell();
    var columnName = wgGetColNameByCell(activeEditCell.element);
    var curRow = activeEditCell.rowElement;
    var curRowIndex = curRow.rowIndex;
    var curCell = grid.GetActiveEditCell().cellIndex;


    if (keyCode == 38) { // if up arrow
        grid.ExitEdit(1, 0, 0);  // exit and update the row if dirty
                
        intervalObj = setInterval(function ()
        {
            if (!grid.IsInProgress)
            {
                activateEditMode(grid, curRowIndex, curRowIndex - 1, columnName, curCell - 1);
                clearInterval(intervalObj);
                intervalObj = null;
            }
        }, 5);

    }
            
    else if (keyCode == 40) {  // if down arrow or enter key
        grid.ExitEdit(1, 0, 0);  // exit and update the row if dirty

        intervalObj = setInterval(function ()
        {
            if (!grid.IsInProgress)
            {
                activateEditMode(grid, curRowIndex, curRowIndex + 1, columnName, curCell - 1);
                clearInterval(intervalObj);
                intervalObj = null;
            }
        }, 5);
    }
    return true;
}&lt;/pre&gt;&lt;p&gt;I attached the page &amp;amp; video regarding this scenario. Please kindly have review on the attached file and let me know your response.&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Hans K.&lt;br&gt;&lt;/p&gt;</description></item><item><title>http://www.intersoftpt.com/Community/WebGrid/the-grid-using-Left-and-Right-Arrow-Keys/</title><link>http://www.intersoftsolutions.com/Community/WebGrid/httpwwwintersoftptcomCommunityWebGridthe-grid-using-Left-and-Right-Arrow-Keys/</link><pubDate>Tue, 15 Jul 2014 00:52:49 GMT</pubDate><dc:creator>BennySun</dc:creator><category>webgrid allow left right key</category><description>&lt;p&gt;Hi ,&lt;/p&gt;&lt;p&gt;I want to use left or right key in webgrid,&amp;nbsp;But I just found the keys to move up and down the line of code, I do not know how to move around key column is implemented, could help me write an example, thank you.&lt;/p&gt;&lt;p&gt;The following are the up and down keys code:&lt;/p&gt;&lt;pre&gt;function WebGrid1_OnEditKeyDown(controlId) {
            var grid = ISGetObject("WebGrid1");

            var totalRows = grid.TotalRows;
            var curRow = grid.GetSelectedObject().rowIndex;
            var curCell = grid.GetActiveEditCell().cellIndex;

            var curRowEl = grid.RootTable.GetRow(curRow);
            var cell = curRowEl.GetCell(curCell - 1);

            // if ESC key
            if (event.keyCode == 27) {
                cell.Select(true);
            }

            // if ENTER key
            if (event.keyCode == 13) {
                event.keyCode = 40;
            }

            // if UP arrow key
            if (event.keyCode == 38) {
                if (curRow &amp;gt; 0) {
                    keyDownRow(curRow, curRow - 1, curCell - 1);
                }
            }

            //if left arrow key
            if (event.keyCode == 37) {
                //
            }

            //if right arrow key
            if (event.keyCode == 39) {

            }

            // if DOWN arrow key
            else if (event.keyCode == 40) {
                if (curRow &amp;lt; totalRows - 1) {
                    keyDownRow(curRow, curRow + 1, curCell - 1);
                }
            }

            return true;

        }

function keyDownRow(curRow, nextRow, cell) {
            var grid = ISGetObject("WebGrid1");
            var nextRowEl = grid.RootTable.GetRow(nextRow);
            var curRowEl = grid.RootTable.GetRow(curRow);
            var cell1 = nextRowEl.GetCell(cell);
            var cell2 = curRowEl.GetCell(cell);
            grid.SetFocus();
            cell2.Select(true);
            nextRowEl.Select(true);
            cell1.ActivateEdit();
        }
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>