Hello,
I am having a web page with 4 webgrids which are placed in a webtab control. Each webgrid is placed in a separate tab.
Since this screen is majorily used for data entry work, users wanted the facility to move to the next grid using the "page down" key stroke.
To implement this I have used the client-side "EditKeyUpHandler" event to see if the "page down" key is pressed in the last cell of any of the grid. In such case the next web tab is first set as selected and then the first cell of the grid in that tab is set active. Below is the code for the same:
function UltraWebGrid1_EditKeyUp(gridName, cellId, key){ var LaborCell = igtbl_getCellById(cellId); if (LaborCell.Column.Key =="LastCell" && key==34) { var myUltraWebGrid1=igtbl_getGridById('<%= UltraWebGrid1.ClientID %>'); myUltraWebGrid1.endEdit(); var ultraTab = igtab_getTabById('<%= UltraWebTab1.ClientID %>'); ultraTab.setSelectedIndex(1); var myUltraWebGrid2=igtbl_getGridById('<%= UltraWebGrid2.ClientID %>'); var myUltraWebGrid2Cell = igtbl_getCellById('ctl00xContentPlaceHolder1xUltraWebTab1xxctl1xUltraWebGrid2_anc_1'); myUltraWebGrid2.setActiveCell(myUltraWebGrid2Cell); // Tell the WebGrid to enter edit mode myUltraWebGrid2.beginEdit();
}}
When the "page down" key is pressed in the last cell of the 4th grid focus is taken to the "Save All" button which saves all the changes to the database in one go. The problem here is that for some reason the data entered in the last row of each grid is not getting saved in the database. I think the issues could be that since I am not hitting the "enter Key"(and using the "page down" key to move to the next grid) in the last row, the grid is not able to understand that a new row has been added.
How can we fix this issue. Please help.
Also, this screen is used only for inserting data, no update or delete opertaion is required.
Thanks,Rajiv
Hello Rajiv,
This is an interesting scenario. From what I see in the code, everything seems correct - the only thing that might be missing is calling the endEdit() method each time with a "force" - true - parameter. Here is what I can see in the docs for endEdit()
http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR3.5/html/WebGrid_Object_CSOM.html
This method can be called of the UltraWebGrid to discontinue editing of the UltraWebGrid and push the changes into the client object model.
Boolean. Optional. Forces exiting edit mode. In some circumstances the grid prevents the editor to be closed, for example the browser can generate minor changes of the elements layout when the editor should stay opened. Using this parameter will close the editor regardless of any external conditions.
So maybe in the custom scenario you are using, you may need to call endEdit(true) to force the grid to save the last edit of the respective cell.
Hope this helps.
Thank for the reply, Rumen.
I tried the force option of the endEdit method but it didn't help. Is there any way to simulate the lost focus event of the last cell usign the client-side code, so that the webgrid will understand that we have finished adding the last row?
Best Regards,
Rajiv
That's a good idea -- maybe you can get the <input> used by the grid fo editing the cell (you can use the FireBug plugin for FireFox and the Inspect Element feature to get it's ID) and then call blur() on it - blur will emulate focus lost and could be what you need.