I am using the UltraWebGrid v8.2. I have enabled the AllAddNewDefault and the AddNewRowDefault options so that a new row is displayed at the bottom of my grid (for entering new data). The first column in my grid is setup as ColumnType.DropDownList and the second column is a double. Whenever a new row is added (after entering data on a previous row and pushing the tab button), I need to set focus on the dropDownList column so that users may user their keyboards to enter data quickly. I tried to setup the AfterRowInserHandler event but it doesn't seem to fire. I do not way to show the "Add..." button for adding rows. Here is the code for my event:
row.getCell(2).activate(); ;
row.getCell(2).beginEdit();
}
Is there a way to set the focus on the row after it has been added?
I should also note that I see a few other items that are causing problems. I have an UpdateRow server side event handler that is firing so that my footers (setup in the Initalize_Layout handler) will display the totals correctly. If I remove the UpdateRow handler, I seem to be getting the focus set on the row that I am editing, not the new row. However, this will not allow my footers to recalculate after the user edits or adds a row.
The code seems correct and I have used something similar like that recently with good success. However I guess in your case the postback event kicks on immediately after the focus, the whole page refreshes after that, so it has no visible effect.
I like what PsychoTeddy has suggested. You can also try running custom javascript the is registered from the UpdateRow postback event handler, using the Page.ClientScript.RegisterStartupScript method - the javascript will be executed after the page refreshes and will put the cell in focus (however the javascript needs to be a bit different, since you will not have some of the parameters in the client-side event handler)
I've attempted a few techniques as both you and PsychoTeddy have mentioned. Neither seem to work and I cannot get the Page.ClientScript.RegisterStartupScript to work correctly (javascript doesn't seem to fire). I am using the ASP.NET Ajax controls on the page with an asp:updatePanel and I have also tried the ScriptManager.RegisterClientScriptBlock to add the javascript. If I use PsychoTeddy's logic, I am able to set the focus on the row that has just been added, but not the blank row. Is is possible for you to give me the javascript?
Currently I am using the the AddRow server side event handler to set the focus of the edited row's cell. The user can then press the down arrow on the keyboard to get into the blank rows cell and begin editing. Although this works, it is not ideal. Any additional help would be appreciated. I certainly appreciate the help thus far.