I have a WebDataGrid on my page, with EnableAjax set to false and EditingCore on with Rowadding enabled and AutoCRUD set to false. However, I can't seem to get the RowAdding event to fire on the server. Here is my markup:
<ig:WebDataGrid ID="datagridTotal" runat="server" Height="95px" AutoGenerateColumns="False" OnInitializeRow="datagridTotal_InitializeRow" EnableDataViewState="True" OnRowAdding="datagridTotal_RowAdding" DataKeyFields="DCType" EnableAjax="False"> <Columns> <ig:BoundDataField DataFieldName="DCType" Key="DCType" Width="49px"> <Header Text="Type"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="DCTotal" DataFormatString="{0:C0}" DataType="System.Decimal" Key="DCTotal" Width="100px" CssClass="Right"> <Header Text="Gifts"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="DCGTotal" Hidden="True" Key="DCGTotal"> <Header Text="BoundColumn_4"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="DCGift" DataFormatString="{0:N0}" DataType="System.Decimal" Key="DCGift" Width="60px" CssClass="Right"> <Header Text="Total"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="DCGGift" Hidden="True" Key="DCGGift"> <Header Text="BoundColumn_2"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="DCMonthly" DataFormatString="{0:C0}" DataType="System.Decimal" Key="DCMonthly" Width="100px" CssClass="Right"> <Header Text="Monthly"> </Header> </ig:BoundDataField> <ig:TemplateDataField Key="DCExp" Width="21px"> <ItemTemplate> <asp:ImageButton ID="btnExpand" runat="server" OnClientClick="popupTotals(); return false;" ImageUrl="~/Images/Expand.png" ToolTip="Expand" /> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="DCAddGoal" Width="21px"> <ItemTemplate> <asp:ImageButton ID="btnAddGoal" runat="server" OnClientClick="popupGoal(); return false;" ImageUrl="~/Images/Goal.png" ToolTip="Goals" /> </ItemTemplate> </ig:TemplateDataField> </Columns> <Behaviors> <ig:EditingCore AutoCRUD="False"> <Behaviors> <ig:RowAdding> </ig:RowAdding> </Behaviors> </ig:EditingCore> <ig:Selection> </ig:Selection> </Behaviors></ig:WebDataGrid>
In the javascript, I add a row to the grid upon returning from another window where I selected the record I want added to the grid.
function FundUpdateResponse() { var chals; var res; var grid = window.opener.$IG.WebDataGrid.find("GBCampaignResults_MainTab_tmpl0_datagridTotal"); if (FundUpdateObj.readyState === 4) { if (FundUpdateObj.status === 200) { var newRecord = new Array(FundUpdateObj.responseText, 0, 0, 0, 0, 0); grid.get_rows().add(newRecord); window.close(); } else { alert(FundUpdateObj.statusText + "-Adding a fund-"); } delete FundUpdateObj.onreadystatechange; FundUpdateObj = null; }}
So my question is, why isn't the RowAdding event firing? The row does show up in the grid. I've even tried turning on batch updating and then doing a commit to the editing core in the script. No dice. Thanks.
I did determine that the pop up window seemed to be the issue with the server side code not firing. I switched from using a popup to a modal popup and now the event does fire. But I'm still curious if there is a solution to this issue when using a popup.
And actually, going backwards from switching to a modal popup, I realized the javascript function where the row is added is being called by the child window, not the main window, thus causing the server side code to not fire. By changing the call of the function to window.opener.AddFundRecord(), it worked. So this can be ignored. Funny how you work on something for days and when you finally break down and post a question, you figure it out soon after. A note: in the code above, since the function is now called by the main window, you would remove window.opener. when defining the grid. Also, the window.close() would be moved to the function called by the pop (after calling this function in there).