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
1635
Extra rows in recursive relationship in Ultragrid
posted

I'm trying to implement an Ultragrid with a recursive relationship. If I have a band zero row and add a child row via the AddNew button, it adds the row correctly but it additionally adds another band zero row. It treats the new rows the same because if I delete eiher of the new rows, both get deleted. How can I avoid the additional band zero rows from appearing? Do I need another relationship? 

Ron

 

 

Parents
  • 469350
    Offline posted

    Hi Ron,

    What kind of data source are you using and how are you setting up your recursive relationship?

    My guess is that you are using a DataSet with a single DataTable in it and a Relationship which relates that table to itself. In a case like that, the row will always show up in two places - at the root level and also at the child level. This has nothing to do with the grid, that's the way the data source is set up. The root level table contains all of the rows and then those same rows may also show up as children.

    There are a few ways you can deal with this.

    1) You could use the InitializeRow event of the grid to hide the rows at the root level which are child rows. Presumably you have some field in your data that indicates the parent row. So you could examine the row, see which band it's in, and if it's in Band 0 and the data indicates that the row is a child row (it has a parent Id), then you could hide that row.

    2) You could use two tables. Your root table would be the result of a query that returns only the root-level rows (rows whose parent Id is null). Then you relate that table to the full table of data and also the full table to itself. You bind the grid to the root-level table.

Reply Children
No Data