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>
Hello,
Thanks for writing. I was able to build a sample project and reproduce something similar. This is quite weird actually - I too would expect a postback to occur immediately after clicking OK, and not on subsequent row blur (focus on another row). So while I was able to find a workaround that may work for you (submitting the form after clicking OK explicitly with this updated code:
<p align="center"> <input id="igtbl_reOkBtn" onclick="igtbl_gRowEditButtonClick(event); document.forms[0].submit();" style="width:50px;" type="button" value="OK"> <input id="igtbl_reCancelBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width:50px;" type="button" value="Cancel"> </input> </input> </p>
I think that you might want to double check with Developer Support if this is something they are aware of and if this is a bug or not (and if so, if it is resolved in a hotfix already).
Developer Support can be reached via the following link:
http://devcenter.infragistics.com/Protected/SubmitSupportIssue.aspx
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.
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.
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
}
Can you show me where and how you called this function? I need the same functionality.