DataGrid: What event fires when clicking on grouped row (+/-)

Posted by: david.mcdonald on 31 March 2020, 5:38 am EST

    • Post Options:
    • Link

    Posted 31 March 2020, 5:38 am EST

    Hello,

    Can you tell me what event fires when you have a grouped header row and you want to click the “+” to expand and then “-” to collapse? I want to intercept the event and display a full subgrid of data.

    Thank you…

    Dave

  • Posted 31 March 2020, 9:42 am EST

    Hi Dave,

    For this, you should handle the CreatingRow event of the C1DataGrid. This event fires for each row when it is being created. Its eventargs expose the Type of the row being created which we can use to check if the row is group row/not. If the row is group row then handle its GroupRowsVisiblityChanged event.

    Following is the code snippet for the same:```

    private void Grid_CreatingRow(object sender, DataGridCreatingRowEventArgs e)

    {

    if(e.Type== DataGridRowType.Group)

    {

    var grpRow = e.Row as DataGridGroupRow;

    if(grpRow != null)

    {

    grpRow.GroupRowsVisibilityChanged += GrpRow_GroupRowsVisibilityChanged;

    }

    }

    }

    private void GrpRow_GroupRowsVisibilityChanged(object sender, PropertyChangedEventArgs e)

    {

    //clicking the +/- icons will trigger this event

    }

    
    With regards,
    Ruchir
  • Posted 1 April 2020, 2:26 am EST

    Hi Ruchir,

    That was exactly what I needed. Thank you very much for the quick response. I appreciate it!

    Have a nice day…

    Dave

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels