Enter_Event issue

2 replies. Last post: October 13, 2010 1:33 AM by Frank Bruce
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Frank BruceMember

 Webgrid  have a column which is "NoEdit" !

 <ISWebGrid:WebGridColumn Width="60px" EditType="NoEdit" Name="idxBox" Caption="myname" >    
  </ISWebGrid:WebGridColumn>

When focus on  "myname"  column, I Press Enter Key,can not tun into next cell !
How can I do to tun into next cell  when have a "NoEdit"  column???

function WebGrid1_OnEditKeyDown(controlId, tblName, rowIndex, cellIndex) {
    var grid = ISGetObject(controlId);
    var totalRows = grid.TotalRows;
    var curRow = grid.GetSelectedObject().rowIndex;
    var curCell = grid.GetActiveEditCell().cellIndex;
    var activeCell = grid.GetActiveEditCell();

    if (activeCell.rowElement.type == "Record") {
        if (event.keyCode == 37)//左键左移
        {
            if (curCell != 1)//不是第一单元,则在该行左移
            {
                MoveAndSelectCell(curRow, curCell - 2);
            } else//如果是第一单元并且不是第一行则上移一行
            {
                if (curRow != 0) {
                    MoveAndSelectCell(curRow - 1, 3);
                }
            }
        }

        if (event.keyCode == 39)//右键右移
        {
            if (curCell != 8)//不是最后单元则在该行移
            {
                MoveAndSelectCell(curRow, curCell);
            } else {
                if (curRow != (totalRows - 1))//不是最后一行,则下移一行.
                {
                    MoveAndSelectCell(curRow + 1, 1);
                }
            }
        }

        if (event.keyCode == 38)//下键上移
        {
        alert('up');
        }
        if (event.keyCode == 40)//下键下移
        {
     
            
            if (curRow < (totalRows - 1))//如果不是最后一行,则下移一行
            {
//                if (curCell != 4) {
//                MoveAndSelectCell(curRow + 1, curCell-1);
//             
//                                     
//                } else {
//                    var WebCombo1 = ISGetObject("WebCombo1");
//                    window.setTimeout(function() { WebCombo1.ShowDropDown(true); }, 100);
//                }
            }
        }

        if (event.keyCode == 13)//如果是回车
        {
            if (curCell == 8) {

                if (curRow == (totalRows - 1)) {
                       
                        var newRow = grid.RootTable.NewRow();
                        var newCells = newRow.GetCells();

                        newCells.GetNamedItem("vouid").SetText(totalRows + 1, true);
                        newCells.GetNamedItem("商品编号").SetText("", true);
                        newCells.GetNamedItem("商品名称").SetText("", true);
                        newCells.GetNamedItem("商品规格").SetText("", true);
                        newCells.GetNamedItem("包装单位").SetText("", true);
                        newCells.GetNamedItem("数量").SetText("", true);
                        newCells.GetNamedItem("价格范围").SetText("", true);
                        newCells.GetNamedItem("备注").SetText("", true);

                  
                        
                        
                        newRow.Update();
                      
                        
                        window.setTimeout(function() { SelectNextRow(curRow + 1); }, 1000);     
                }
                else {
                    var nextCell = grid.RootTable.GetRow(curRow + 1).GetCell(1);
                    grid.SetFocus();
                    grid.RootTable.GetRow(curRow + 1).Select();
                    nextCell.ActivateEdit();
                }
                event.keyCode = null;
            } else {
                event.keyCode = 9;
            }
        }
    }
    return true;
}

function WebGrid1_OnEditKeyDown(controlId, tblName, rowIndex, cellIndex) {
    var grid = ISGetObject(controlId);
    var totalRows = grid.TotalRows;
    var curRow = grid.GetSelectedObject().rowIndex;
    var curCell = grid.GetActiveEditCell().cellIndex;
    var activeCell = grid.GetActiveEditCell();

    if (activeCell.rowElement.type == "Record") {
        if (event.keyCode == 37)//左键左移
        {
            if (curCell != 1)//不是第一单元,则在该行左移
            {
                MoveAndSelectCell(curRow, curCell - 2);
            } else//如果是第一单元并且不是第一行则上移一行
            {
                if (curRow != 0) {
                    MoveAndSelectCell(curRow - 1, 3);
                }
            }
        }

        if (event.keyCode == 39)//右键右移
        {
            if (curCell != 8)//不是最后单元则在该行移
            {
                MoveAndSelectCell(curRow, curCell);
            } else {
                if (curRow != (totalRows - 1))//不是最后一行,则下移一行.
                {
                    MoveAndSelectCell(curRow + 1, 1);
                }
            }
        }

        if (event.keyCode == 38)//下键上移
        {
        alert('up');
        }
        if (event.keyCode == 40)//下键下移
        {
     
            
            if (curRow < (totalRows - 1))//如果不是最后一行,则下移一行
            {
//                if (curCell != 4) {
//                MoveAndSelectCell(curRow + 1, curCell-1);
//             
//                                     
//                } else {
//                    var WebCombo1 = ISGetObject("WebCombo1");
//                    window.setTimeout(function() { WebCombo1.ShowDropDown(true); }, 100);
//                }
            }
        }

        if (event.keyCode == 13)//如果是回车
        {
            if (curCell == 8) {

                if (curRow == (totalRows - 1)) {
                       
                        var newRow = grid.RootTable.NewRow();
                        var newCells = newRow.GetCells();

                        newCells.GetNamedItem("vouid").SetText(totalRows + 1, true);
                        newCells.GetNamedItem("商品编号").SetText("", true);
                        newCells.GetNamedItem("商品名称").SetText("", true);
                        newCells.GetNamedItem("商品规格").SetText("", true);
                        newCells.GetNamedItem("包装单位").SetText("", true);
                        newCells.GetNamedItem("数量").SetText("", true);
                        newCells.GetNamedItem("价格范围").SetText("", true);
                        newCells.GetNamedItem("备注").SetText("", true);

                  
                        
                        
                        newRow.Update();
                      
                        
                        window.setTimeout(function() { SelectNextRow(curRow + 1); }, 1000);     
                }
                else {
                    var nextCell = grid.RootTable.GetRow(curRow + 1).GetCell(1);
                    grid.SetFocus();
                    grid.RootTable.GetRow(curRow + 1).Select();
                    nextCell.ActivateEdit();
                }
                event.keyCode = null;
            } else {
                event.keyCode = 9;
            }
        }
    }
    return true;
}
All times are GMT -5. The time now is 1:00 AM.
Previous Next