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

How can i Get selected cell value?

2 Answers 205 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Jeongmin
Top achievements
Rank 1
Jeongmin asked on 01 Aug 2013, 07:04 AM
How can i Get selected cell value and all value ?

I test code. but GetCellElement method always return null.
what's wrong? Help me.

 

private void rndButton1_Click(object sender, EventArgs e)
        {
            foreach (PivotGroupNode rowNode in this.radPivotGrid1.PivotGridElement.GetRowGroups())
            {
                if (rowNode.Group == null) continue;
                foreach (PivotGroupNode columnNode in this.radPivotGrid1.PivotGridElement.GetColumnGroups())
                {
                    if (columnNode.Group == null) continue;

                    var cell = this.radPivotGrid1.PivotGridElement.GetCellElement(columnNode, rowNode);

                    if (cell == null) continue;  <== always return null
                    Console.Write(cell.Value);
                }
            }
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Barry
Top achievements
Rank 1
answered on 02 Aug 2013, 12:22 AM
You have the reversed the columnNode and row Node in the GetCellElelment method's parameters.

Your code is:
var cell = this.radPivotGrid1.PivotGridElement.GetCellElement(columnNode, rowNode);

The correct code is:
var cell = rPivot.PivotGridElement.GetCellElement(rowNode, columnNode);

I am using the following line to get a cell value:
CellAggregateValue value = this.rPivot.PivotGridElement.GetAggregateValue(rowNode.Group, columnNode.Group, true, true);

I had done exactly the same as you - reversed the order of the rowNode & columnNode parameters. It was looking at you posting that enabled me to sort out my own problem!

Thanks for the posting.

Barry
0
Accepted
Peter
Telerik team
answered on 05 Aug 2013, 03:23 PM
Hello,

I can confirm that the Barry's approach is the right way to get the cell value.

@Barry, I have updated your 
Telerik Points for the community efforts.

Regards,
Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
PivotGrid and PivotFieldList
Asked by
Jeongmin
Top achievements
Rank 1
Answers by
Barry
Top achievements
Rank 1
Peter
Telerik team
Share this question
or