iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
/** * Some manual behavior for navigating the grid */ function wb_OnEditKeyDown(controlId, keyCode) { var returnVal = true; // get the grid var grid = ISGetObject(controlId); // get current information about row and cell var activeEditCell = grid.GetActiveEditCell(); var curRow = activeEditCell.rowElement; var curRowIndex = curRow.rowIndex; var curCell = grid.GetActiveEditCell().cellIndex; var curRowEl = grid.RootTable.GetRow(curRowIndex); var cell = curRowEl.GetCell(curCell - 1); if (keyCode == 38) { // if up arrow grid.ExitEdit(1, 0, 0); // exit and update the row if dirty activateEditMode(grid, curRowIndex, curRowIndex - 1, curCell - 1); } else if (keyCode == 40 || keyCode == 13) { // if down arrow or enter key keyCode = 40; event.keyCode = 40; //returnVal = true; event.returnValue = false; grid.ExitEdit(1, 0, 0); // exit and update the row if dirty activateEditMode(grid, curRowIndex, curRowIndex + 1, curCell - 1); } else if (keyCode == 27) { // esc key cell.Select(true); } return returnVal; }
This works. I found out the issue with focus. I was causing a differnet Refresh on the OnUpdating event.
But this isn't the full solution. I marked the answer too soon.
Now in Firefox, the edit makes it through and I'm set in the edit mode for the cell directly under. That's good. However, if I hit 'esc' key, it takes me to the first cell in that row. Why does that happen and how can I stop that from happening?
In IE 9, it goes directly to the first cell in the next row.
This works fine, but I still have the problem of losing focus on the cell. The focus goes back on the browser window and not the cell. So then if I click left or right, I am no longer navigating in the grid.
If you can't recreate the issue, can you tell me why in IE the body element takes focus instead of it going back to the grid?
I am trying to get on the Live Chat for techinical assistance and it won't let me due to some user name and password. Can you please provide so I may solve this problem?
I've checked out the article. The real issue is on this thread: http://intersoftpt.com/Community/WebGrid/Updating-the-grid-using-Enter-and-Down-Arrow-Keys/?1350933280442
Thanks for your response.
Hans,Thanks for the answer. It's almost there... The up and down arrow and enter keys work just fine with Firefox. They almost work in IE.
I am having a weird scroll issue as presented in the attached screen shots. The grid scroll bar (I have 80+ columns) shifts back over to the left. I already have code that will preserve the horizontal scroll position of the grid (got the solution from asking the forum), and that works just fine in Firefox and usually in IE except in this case. It works fine in both browsers if I "mouse-off" the cell. The other issue in IE is the control-focus becomes on the grid control and not on a cell. So clicking the right or left arrow after this will scoll the page left or right, rather than the cell cursor.
My latest implementation is as follows:
function wbAARS_OnEditKeyDown(controlId, keyCode) { var returnVal = true; // 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 activateEditMode(grid, curRowIndex, curRowIndex - 1, columnName, curCell - 1); } else if (keyCode == 40) { // if down arrow grid.ExitEdit(1, 0, 0); // exit and update the row if dirty activateEditMode(grid, curRowIndex, curRowIndex + 1, columnName, curCell - 1); } else if (keyCode == 13) { // enter key event.returnValue = false; grid.ExitEdit(1, 0, 0); window.setTimeout(function () { activateEditMode(grid, curRowIndex, curRowIndex + 1, columnName, curCell - 1); }, 500); // return false; returnVal = false; } // return true; return returnVal; }
function activateEditMode(grid, curRowIndex, nextRowIndex, columnName, cell) { if (nextRowIndex != 0 && nextRowIndex < 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(); } }
Below is how I apply my scrolling preservation:
ram name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Private Sub wb_InitializePostBack(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.PostbackEventArgs) Handles wb.InitializePostBack ' only perform the below function ' when the last action performed by the ' grid OTFPB is 'Refresh' If e.Action.Equals("Refresh") Then ' prepare the parameter to be ' passed over to the client side ' in order to set back the previous ' vertical and horizontal scroll position 'FunctionParameter(parm = New FunctionParameter(2)) Dim parm(2) As ISNet.WebUI.FunctionParameter parm(0).Type = "gridId" parm(1).Type = "y" parm(2).Type = "x" ' obtain the value passed from the client ' side using AddInput method parm(0).Value = Me.wb.ID parm(1).Value = Request.Form("scrollTopPos") parm(2).Value = Request.Form("scrollLeftPos") ' invoke the js function ' in order to set the vertical scroll position Me.wb.ClientAction.InvokeScript("ApplyLatestScroll", parm) End If End Sub
''' <summary> ''' Initializes the web grid layout ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Private Sub wb_InitializeLayout(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.LayoutEventArgs) Handles wb.InitializeLayout ' saving scroll position e.Layout.ClientSideEvents.OnBeforeRequest = "SaveScrollPosition" End Sub
/** ` * Applies the latest scroll position to the grid */ function ApplyLatestScroll(gridId, y, x) { // set back the previous scrollTop and scrollLeft property or // vertical and horizontal scroll position with // the parameter sent from the server side var grid = ISGetObject(gridId); // manually configure the vertical and horizontal scroll position grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV).scrollTop = y; grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV).scrollLeft = x; return true; }
/** * saves the last scroll position of the grid */ function SaveScrollPosition(gridId, action) { // collecting the last position // of the vertical scrollbar // by obtaining the scrollTop property var grid = ISGetObject(gridId); // obtain the scrollTop and scrollLeft property // of the vertical scrollbar and horizontal scrollbar var vl = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV).scrollTop + ""; var hl = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV).scrollLeft + ""; // only send the scrollTop property // of the server if the action performed // by the grid OTFPB is 'Refresh' if (action == "Refresh") { // sending over the scrollTop and scrollLeft property // to the server by using AddInput method grid.AddInput("scrollTopPos", vl); grid.AddInput("scrollLeftPos", hl); } return true; }
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname