This is a migrated thread and some comments may be shown as answers.

Find Selected Cell Range in RadPivotGridView

1 Answer 136 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 12 Mar 2018, 10:02 AM

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.

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 12 Mar 2018, 03:03 PM
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.
Tags
General Discussions
Asked by
Amit
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or