I have a WebGrid on a page. From time to time the user will click on something else on the page (like a button that causes a WebDialogWindow to display). When the user closes the WebDialogWindow, I would like to return the focus to the WebGrid. I don't need to open any editors on the grid, just get the focus back there.
For an asp.net control, I would just use control.focus(), but the grid doesn't have a focus method...
How do I get the next keystroke to go to the active cell of the grid (without calling beginEdit)?
Thanks,
DaveL
Hi DaveL,
The UltraWebGrid has the Focus method. Please visit the following link to learn more about UltraWebGrid properties and methods.
http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR2.0/html/Infragistics2.WebUI.UltraWebGrid.v8.3~Infragistics.WebUI.UltraWebGrid.UltraWebGrid_members.html
To make a cell active with a keystoke, you can handle the KeyDown or KeyUp event on the client side and activate the cell you want. Here is the link to CSOM of WebGrid.
http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR2.0/html/WebGrid_CSOM_Overview.html
Please visit the links and let me know if you have any other questions or concerns.
Thanks
I see that I left out one small detail...
Your pointer concerns server-side methods. I need to do this on the client. That's why I was using the example of "control.focus()" rather than "control.Focus()".
What I need is to understand how to do the equivalent of the following on the client using BLOCKED SCRIPT
var foo = igtbl_getGridById("UltraWebGrid1");foo.focus();
When I run this code I get the error "Microsoft JScript runtime error: Object doesn't support this property or method"
Sorry about the confusion.
The trouble with calling cell.activate() is that apparently the grid code optimizes away any call to activate the cell that is currently active. Consider the following:
var grid = igtbl_getGridById("UltraWebGrid1");
var cell = grid .getActiveCell();>
cell.activate();
In this case, the grid does not get focus since the cell.activate() call is activating the already active (but without focus) cell. To make cell.activate() work for assigning focus, I need to activate something else in the grid and then activate the cell that was originally active. I was hoping to avoid this unnecessary work by simply giving focus to the grid.
It sounds like there really isn't any way to just focus on a grid.
Hello Dave,
You can achieve this using the client-side object model (CSOM) of the grid to get the first cell and focus it. This can be achieved using the "activate()" method of the cell. More info on what is available at the client-side cell object model can be found here:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/WebGrid_cell_Object_CSOM.html
One sample code can be found here:
http://forums.infragistics.com/forums/p/12988/48099.aspx#48099
Hope this helps.