Hello, I'm having a big problem here. I'm using a WHDG with a WebHierarchicalDataSource connected to 2 SQLDataSources for editing a master-Detail view.
This is how my grid is defined:
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" ClientIDMode="Static" Width="100%" runat="server" AutoGenerateColumns="False" ValidateRequestMode="Disabled" AutoGenerateBands="False" DataKeyFields="ID" DataMember="SqlDataSource1_DefaultView" DataSourceID="WebHierarchicalDataSource1" Key="SqlDataSource1_DefaultView" OnRowUpdating="WebDataGrid1_RowUpdating" >
<Bands> <ig:Band AutoGenerateColumns="False" DataMember="SqlDataSource2_DefaultView" Key="SqlDataSource2_DefaultView" DataKeyFields="ID, CHILD_ID" OnRowUpdating="WebDataGrid1_RowUpdating"> <Columns> <ig:BoundDataField DataFieldName="ID" Key="ID" Hidden="true"> <Header Text="ID">Header> ig:BoundDataField>
<ig:BoundDataField DataFieldName="CHILD_ID" Key="CHILD_ID"> <Header Text="CHILD_ID">Header> ig:BoundDataField>
Columns> ig:Band>
Bands>
<Columns>
<ig:BoundDataField DataFieldName="ID" Key="ID" Hidden="true">
<Header Text="ID">
Header>
ig:BoundDataField>
<ig:BoundDataField DataFieldName="DESCRIPTION" Key="DESCRIPTION">
<Header Text="DESCRIPTION">
Columns>
<Behaviors>
<ig:EditingCore AutoCRUD="False" BatchUpdating="True" EnableInheritance="true">
<ig:RowEditing EnableInheritance="true">
ig:RowEditing >
<ig:RowDeleting EnableInheritance="true">
ig:RowDeleting>
<ig:RowAdding EnableInheritance="true">
ig:RowAdding>
Behaviors>
ig:EditingCore>
ig:WebHierarchicalDataGrid>
Then I'm calling the following JavaScript function when clicking on a Save-Button:
function commitWHDGrid() {
var editingCore = $find("WebHierarchicalDataGrid1").get_gridView().get_behaviors().get_editingCore();
NProgress.start();
$find("WebHierarchicalDataGrid1").get_gridView().get_behaviors().get_editingCore().commit();
return false;
}
When I edit a row in the Master-View (the main grid), and then click the button, my RowUpdating method is being called. When I on the other Hand, update one of the child grid rows and press the button, the onRowUpdating Event is not being called.
What am I doing wrong?
For the sake of completeness:
protected void WebDataGrid1_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e)
{
ContainerGrid grid = ((ContainerGrid)sender);
if (grid.Level == 0)
// update in main grid occured
SqlDataSource1.UpdateParameters["ID"].DefaultValue = e.OldValues["ID"].ToString();
.....
}else{
// update in child grid occured
SqlDataSource2.UpdateParameters["ID"].DefaultValue = e.OldValues["ID"].ToString();
WebHierarchicalDataGrid1.Rows.Clear();
WebHierarchicalDataGrid1.DataBind();
WebHierarchicalDataGrid1.GridView.RequestFullAsyncRender();
Hello Marc,
Most likely the issue is that you are clearing the rows and rebinding the grid in your RowUpdating event. Is there any reason that you have this logic placed here? Other than that, another issue I see is that the only fields you appear to have in your child grid are part of the DataKeyFields setting, which means these are used as the primary key and should not be allowed to change. Do you have additional columns that you are allowing editing on or is it just the one visible ChildID column? Is this required to be specified as part of the DataKeyFields?
Other than this, updating logic should work without issue for the children and the parents. Is there a specific build of the Infragistics for ASP.NET controls that causes this issue?
Hello Jason
To be honest, I don't remember the reason why I do the clearing and rebinding, but most likely it had something to do with the RequestFullAsyncRender not working properly without rebinding it first. Remember, my goal is to do the whole CRUD operations asynchronously and without updatepanels, so RequestFullAsyncRender was working perfectly fine on a WebDataGrid (nonhierarchical).
However, as the RowUpdating is not even called when updating the child grids, I suppose that cannot cause the Problem (I just removed the rebinding though but it didn't help).
About the key: Yes you are right, there is just an ID (which refers to the parent of the child) and the childId and only together they form an unique primarykey. For testing I just removed the ID from the keyfields, but it doesn't solve the problem.
In the meantime, I tried removing batchupdating and/or adding the following code
function WebHierarchicalDataGrid1_RowEdit_ExitedEditMode(sender, eventArgs) {
sender.get_behaviors().get_editingCore().commit();
which solves the problem. The RowUpdating Event is now being called even for the child grids. I then checked the Sender object and noticed that the maingrid and the child grids have different id's, like:
ctl00$MainContent$WebHierarchicalDataGrid1$ctl00ctl00_MainContent_WebHierarchicalDataGrid1_ctl00_10_0
Do I somehow Need to call .commit() not on only on the maingrid but also on all childgrids to make it work with batchupdating?