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
120
Don't show "plus" expand indicator in hierarchical dataset if the child table is empty
posted

I have a hierarchical dataset bound as the datasource to a datagrid.  The rows in the parent table show up in the grid, and all the rows have an expansion indicator on their left.  However, some of the rows in my datasource do not have corresponding rows in the child table.  For these, I don't want the expansion indicator to appear, so that the user can easily tell which rows have children and which do not.  Is this possible?

 

thanks,

- Kam

  • 120
    posted

    I just figured this out, and figure I'd post it here in case anyone else was interested: 

    Handle the InitializeRecord event, and in your handler set the Record's ExpansionIndicatorVisibility propery according:

     e.g.

            private void OnInitializeRecord(object sender, InitializeRecordEventArgs e)
            {
                if (e.Record != null)
                {
                    if (e.Record.HasChildren)
                        e.Record.ExpansionIndicatorVisibility = Visibility.Visible;
                    else
                        e.Record.ExpansionIndicatorVisibility = Visibility.Hidden;
                }

            }