Reconfigure the "Enter" key functions on EditMode

4 replies. Last post: September 1, 2009 6:16 AM by James
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Zahid Member

I need the behaviour of MS Excel while editing the grid cells. After users modified a cell content followed by pressing Enter key the next cell at the next row (rowIndex+1) at the same column will be directly highlighted.

 

I got a solution from

http://support.intersoftpt.com/docs/webgrid/5.0.7200/Reconfigure%20the%20Enter%20key%20functions%20on%20EditMode.html

 It is as follows

function WebGrid1_OnEditKeyDown(controlId)
{
if(event.keyCode == 13) {
//cancel the event as it'll be handled manually
event.returnValue = false;

var grid = ISGetObject("WebGrid1");

//get currently active edit cell
var ac = grid.GetActiveEditCell();

if(ac.rowElement.type == "Record") {
//get the table object
var tbl = grid.Tables[ac.tblName];
grid.ExitEdit(1,0,0) // exit and update the row if dirty
     //find out if the table of current row is parent
var isParent = (tbl.GetChildTables().length > 0)?true : false;

window.setTimeout(function() {SelectNext(ac, isParent);},500);

//you can try to remove this line if you receive a javascript error
return false;
}
}
return true;
}

function SelectNext(ac, isParent) {
var curRow = ac.rowElement;
var tblElm = wgGetTable(curRow);
var curRowIndex = curRow.rowIndex;

//if a table is a parent, the index numbering increases by 2
var i = (isParent)? 2 : 1;

//check if current row is the last row of the table
if(curRowIndex < tblElm.rows.length-i){
//get destination now
var destRow = wgGetRowByPosition(tblElm, curRowIndex+i);

//highlight the destination row
//wgHighlightROw(destRow);

//get the column name
var cellName = wgGetColNameByCell(ac.element);

//get the destination cell
var destCell = wgGetCellByName(destRow, cellName);

//select nextRow and highlight the destination cell
window.setTimeout(function() { MoveRow(destRow,destCell);}, 500);

}
}

function MoveRow(destRow, destCell)
{
wgGetRowByElement(destRow).Select();
wgHighlightEditCell(destCell);
}

 

The proble with this is in wgGetRowByElement(destRow).Select()

When i have columns outside the viewable area and the horizontal scrollbar is enabled. Then when i select the next row, the horizontal scroll bar flickers. that is, it goes to position 0 (zero) and comes back to appropriate position to focus the highlighted cell. I want to keep the scroll bar fixed.

 

Any idea of this? 

 

Thanks

Zahid

 

 

 

 

 

All times are GMT -5. The time now is 1:37 AM.
Previous Next