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

A way to get 'underlying' rows

4 Answers 191 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Ilya
Top achievements
Rank 1
Ilya asked on 21 Jul 2013, 06:49 PM
Greetings!

I would like to know, how can I get all the rows that 'lie' beneath a visible cell value. So, for example, i have a cell value which is composed from two (or more) rows in pivots`s datasource. I want to get those rows somehow. Is it possible?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Ilya
Top achievements
Rank 1
answered on 22 Jul 2013, 03:16 PM
I`ve found an example of how Devexpress team made it. Look here: http://documentation.devexpress.com/#WindowsForms/CustomDocument1884

Is it possible in Telerik?
0
Accepted
Paul
Telerik team
answered on 25 Jul 2013, 06:06 AM
Hello Ilya,

Thank you for writing.

Currently Telerik PivotGrid does not support such functionality, but we will consider implementing it in a future release.

Please let us know if we can assist you with anything else.

Regards,
Paul
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 >>
0
Barry
Top achievements
Rank 1
answered on 02 Aug 2013, 04:30 AM
Yes, you can get the underlying rows!

But it would be nice if Telerik provided a more straight forward method!

The code below uses the pivot controls mouse click event to select all the contributing rows to an aggregate value in a girdview bound to the same datasource as the pivot table. The code only handles a simple column aggregate, but handles more complex row scenarios. It should be straight forward to translate the row logic into column logic. I have tested that it works for a few scenarios - but the code has not been tested exhaustively, anybody using this code should check it meets their needs. If anybody has an improved version (or a better method), please post it back on this forum.

In the code:
              rPivot is a radPivotGrid control,
 frmSiteVisits.rgvSiteVisits refers to a GridView on a different form bound to the same data source as rPivot.

private void rPivot_MouseClick(object sender, MouseEventArgs e)
        {
            PivotCellElement currentCell = rPivot.PivotGridElement.ElementTree.GetElementAtPoint(e.Location) as PivotCellElement;
            
            if (currentCell != null)
            {
                string column = currentCell.Column.Name;
                string rowName = currentCell.Row.Name;
 
                PivotGroupNode currentRow = currentCell.Row;
                string columnPropertyName = rPivot.ColumnGroupDescriptions[0].GetUniqueName();
                int level = currentCell.Row.Group.Level;
                if (rPivot.AggregateDescriptions.Count > 1)
                {
                    level = level - 1;
                    if (level < 0)
                    {
                        level = 0;
                        rowName = currentCell.Row.Name;
                        currentRow = currentCell.Row;
                    }
                    else
                    {
                        rowName = currentCell.Row.Parent.Name;
                        currentRow = currentCell.Row.Parent;
                    }
                }
                string rowPropertyName = rPivot.RowGroupDescriptions[level].GetUniqueName();
                 
                if (currentCell.IsInSubTotalRow)
                {
                    rowName = currentCell.Row.Parent.Name;
                    rowPropertyName = rPivot.RowGroupDescriptions[level-1].GetUniqueName();
                }
 
                frmSiteVisits.rgvSiteVisits.FilterDescriptors.Clear();
                if (!currentCell.IsInGrandTotalColumn)
                {
                    frmSiteVisits.rgvSiteVisits.FilterDescriptors.Add(columnPropertyName, Telerik.WinControls.Data.FilterOperator.IsEqualTo, column);
                }
                if (!currentCell.IsInGrandTotalRow)
                {
                    frmSiteVisits.rgvSiteVisits.FilterDescriptors.Add(rowPropertyName, Telerik.WinControls.Data.FilterOperator.IsEqualTo, rowName);
                    while (level > 0)
                    {
                        level -= 1;
                        currentRow = currentRow.Parent;
                        rowName = currentRow.Name;
                        rowPropertyName = rPivot.RowGroupDescriptions[level].GetUniqueName();
                        frmSiteVisits.rgvSiteVisits.FilterDescriptors.Add(rowPropertyName, Telerik.WinControls.Data.FilterOperator.IsEqualTo, rowName);
                    }
                     
                }       
            }
        }

Barry
0
Paul
Telerik team
answered on 06 Aug 2013, 05:49 PM
Hello Barry,

Thank you for the effort and supplied code.

The idea of using the grid view for holding the data is really good.
I believe that the community will benefit from your ideas.
I have added some Telerik points to your account for your contribution.

Regards,
Paul
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
Ilya
Top achievements
Rank 1
Answers by
Ilya
Top achievements
Rank 1
Paul
Telerik team
Barry
Top achievements
Rank 1
Share this question
or