Hi,
I have a webgrid that uses a row template to edit some field of the row. This works fine, except that the row is only updated in the database if the user tabs or clicks out of the row, and they don't seem to be doing that. Is there a way I can force the focus to leave the row when they click the OK button in the template to trigger the DB update?
Any suggestions would be appreciated. Thanks!
Here's a sample of the grid:
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" Browser="Xml" DataSourceID="SqlDataSource1" DataMember="DefaultView" EnableAppStyling="True" EnableTheming="False" StyleSetName="CMTool" StyleSetPath="ig_res" OnInitializeRow="UltraWebGrid1_InitializeRow" DataKeyField="DocId">
<Bands>
<igtbl:UltraGridBand SelectTypeRow="Extended" AllowUpdate="RowTemplateOnly" DataKeyField="DocId">
<Columns>...</Columns>
<RowEditTemplate>
[Template Input fields here...]
<input id="igtbl_reOkBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px" type="button" value="OK" />
<input id="igtbl_reCancelBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px"type="button" value="Cancel" />
</RowEditTemplate>
Can you show me where and how you called this function? I need the same functionality.
Thanks for posting your confirmation - I'm glad it helped, and I hope it's helpful for others as well. This indeed looks like the code I was picturing.
Yes, this did the trick, thank you!
The function I am using is:
function UltraWebGrid1_AfterRowTemplateCloseHandler(gridName, rowId, bSaveChanges){
//Check to see which button in the Row Template fired this event
}
Try handling the grids's AfterRowTemplateClose client-side event, and calling the processUpdateRow() function of the row.
Note that this event is raised regardless of how the template is closed. I think there's a way to determine what control caused the template to close, so that you could verify that it was your "OK" button, but I don't currently recall how.
That is one way of doing it, but then that defeats the purpose of using XML Load on Demand. It states in the documentation ( I am using NetAdvantage 2007 Vol2, by the way) that "If LoadOnDemand is set to Xml, UpdateRow is raised out-of-band, immediately after focus leaves the row".
Since this works in my application as long as the user clicks elsewhere in the grid, I thought I could just use some javascript to force the focus to another row in the grid when the user clicks OK. However I am not sure how to do this with the UltraWebGrid object.
I will have to use the postback option for now, but I hope there is another way to accomplish this.