Find Selected Cell Range in RadPivotGridView

2 posts, 0 answers
  1. Amit
    Amit avatar
    4 posts
    Member since:
    Mar 2018

    Posted 12 Mar 2018 Link to this post

    I need to find the selected range of cells in a radPivotGridView. 

    After I load the radPivotGrid with appropriate DataSources' binding, I need to find when the user has made a selection(i.e. once he releases the left mouse button) on the data displayed under it. I tried to use the MouseCapture event but was unable to access the selected info. in any way.

    Kindly help.

  2. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 12 Mar 2018 Link to this post

    Hello Amit,

    Thank you for writing.

    The selection relies on an internal SelectionHelper class and it is not exposed publicly. You can get the selected cells by handling the SelectionChanged event and iterating the row and column groups:
    private void RadPivotGrid1_SelectionChanged(object sender, EventArgs e)
    {
        var rowGroups = radPivotGrid1.PivotGridElement.GetRowGroups();
        var colGroups = radPivotGrid1.PivotGridElement.GetColumnGroups();
        foreach (PivotGroupNode row in rowGroups)
        {
            if (!row.IsLeaf)
            {
                continue;
            }
     
            foreach (PivotGroupNode col in colGroups)
            {
                if (!col.IsLeaf)
                {
                    continue;
                }
     
                if (row.Group != null && col.Group != null)
                {
                    if (this.radPivotGrid1.PivotGridElement.IsCellSelected(row, col))
                    {
                        object value = this.radPivotGrid1.PivotGridElement.GetAggregateValue(row.Group, col.Group, false, false);
                        Debug.WriteLine("Row = {0} , Column ={1}, Value ={2}", row.Name, col.Name, value);
                    }
                }
            }
        }
    }

    I hope this information is useful. Let me know if you need further assistance.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top