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
115
UltraGrid Recursive Relation
posted

I am defining a dataset with a recursive relation, but ultragrid datasource is duplicating the bands.

is there a way to fix this?

Thanks

  • 21795
    Verified Answer
    Offline posted

    Hello Fatih,

    Form the screenshot you posted it seems that grid is showing the data correctly. In the upper part of the picture you have a table with three rows. I suppose this is the information you have in your backend data model. In the lower part of the screenshot there is a grid showing the same rows.

    One more thing. You said that your dataset is with recursive relation. Did you mean that you have selfreferencing table, e.g. second row with GroupID 13 and GroupMasterID 12 is referring the first row with GroupID of 12? If this is your case grid again shows the data correctly. Once you have a table containing the parent rows. And secondary you have child bands showing the child rows.

    If what you need is to see only the parent rows you may set MaxBandDepth property to 1, like this:

    this.ultraGrid1.DisplayLayout.MaxBandDepth = 1;

    This will force the grid to show only the first level of bands.

    If what you need is to show only the rows which do not have parent row you may hide all other rows in InitializeRow event like this:

    private void UltraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
    {
        //  Check if row Reinitialize. If so just return as you do not need
        //  to hide it again
        if(e.ReInitialize)
        {
            return;
        }

        if(e.Row.Cells.Exists("GroupMasterID") &&
          (int)e.Row.Cells["GroupMasterID "].Value == 0)
        {
            e.Row.Hidden = true;
        }
    }

    Please let me know if this solves your issue or if you have any additional questions.