Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
addnew method error in hierarchical data binding
posted

The help document of Infragistics 7.3 says "If the current ActiveRow does not provide enough context, then an error is thrown. ActiveRow needs to be on a sibling band or a parent band. "
code 1:
For bandcount As Integer = 0 To 2
        .DisplayLayout.Bands(bandcount).Override.AllowAddNew = AllowAddNew.Yes
Next bandcount
.DisplayLayout.Bands(X).AddNew()

code 2:
For bandcount As Integer = 0 To 2
        .DisplayLayout.Bands(bandcount).Override.AllowAddNew = AllowAddNew.Yes
Next bandcount
If .Selected.Rows(0).HasParent Then
   .Selected.Rows(0).ParentRow.Activate()
   .Selected.Rows(0).ParentRow.Selected = True
Else
    .Selected.Rows(0).Activate()
End If
.DisplayLayout.Bands(X).AddNew()


The "AddNew()" method works fine when x=0 but error when x=1 or 2.Why?

Parents
  • 469350
    Verified Answer
    Offline posted

     Hi,

          I'm not sure what you are trying to do here, but this code doesn't make a lot of sense. Adding a row to the root-level of the grid is fine. But when you add a row to a child level, the grid needs some sort of context. It needs to know to what parent row you are adding a child row. The way you have this code set up, even if it worked, you would essentially be adding an empty row to the root level and then an empty row as the child of the first row and then another empty row as a child fo the first child row. 

        It looks to me like you are trying to simulate having an add row show up on each island of data. But you don't have to simulate this, you can do it by setting AllowAddNew to TemplateOnBottom.

        And by the way, you don't need to loop through the bands and do this on each one, you can do it on the grid.DisplayLayout.Override to apply this setting to all bands.  

Reply Children
No Data