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)
Maybe one of this could work:
grid.Rows[0].Activate();
grid.DisplayLayout.Rows[0].Activate();