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

Duplicate a RadPivotgrid Data

8 Answers 128 Views
Documentation
This is a migrated thread and some comments may be shown as answers.
Tiago
Top achievements
Rank 1
Tiago asked on 13 Jan 2015, 02:56 PM
Please, I need a Help
This is my situation, I need to clone data through two RadPivotgrids, Pivotgrid 1 has data  I need, and I need that the pivotgrid 2 has the same data including the group conditions and filters in real time. Is it posible?




My version: 2014.3.1104.40

8 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 15 Jan 2015, 03:01 PM
Hi Tiago,

Thank you for writing.

In order to achieve the desired functionality you can copy all the descriptors from the first grid to the second. You should create a copy of the data source as well:
private void radButton1_Click(object sender, EventArgs e)
{
    foreach (IGroupDescription item in radPivotGrid1.RowGroupDescriptions)
    {
        IGroupDescription desc = item.Clone() as IGroupDescription;
        radPivotGrid2.RowGroupDescriptions.Add(desc);
    }
    foreach (IGroupDescription item in radPivotGrid1.ColumnGroupDescriptions)
    {
        IGroupDescription desc = item.Clone() as IGroupDescription;
        radPivotGrid2.ColumnGroupDescriptions.Add(desc);
    }
    foreach (IAggregateDescriptionitem in radPivotGrid1.AggregateDescriptions)
    {
        IAggregateDescription desc = item.Clone() as IAggregateDescription;
        radPivotGrid2.AggregateDescriptions.Add(desc);
    }
  
    NwindDataSet newDataSet = ((NwindDataSet)radPivotGrid1.DataSource).Copy() as NwindDataSet;
   
    radPivotGrid2.DataSource = newDataSet;
    radPivotGrid2.DataMember = radPivotGrid1.DataMember;
      
}

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tiago
Top achievements
Rank 1
answered on 15 Jan 2015, 04:12 PM
Thank you very much for the excellent support provided , really helped - me.
0
Tiago
Top achievements
Rank 1
answered on 16 Jan 2015, 11:34 AM
I would like to thank the great help given!
For documentation purposes, Below is the code, suitable for vb.net language, the solution worked perfectly

Private Sub radButton1_Click(sender As System.Object, e As System.EventArgs) Handles radButton1.Click
    For Each item As IGroupDescription In pivotGrid.RowGroupDescriptions
        Dim desc As IGroupDescription = item.Clone() 'as IGroupDescription
        PivotGrid1.RowGroupDescriptions.Add(desc)
    Next
 
    For Each item As IGroupDescription In pivotGrid.ColumnGroupDescriptions
        Dim desc As IGroupDescription = item.Clone()
        PivotGrid1.ColumnGroupDescriptions.Add(desc)
    Next
 
    For Each item As IAggregateDescription In pivotGrid.AggregateDescriptions
        Dim desc As IAggregateDescription = item.Clone()
        PivotGrid1.AggregateDescriptions.Add(desc)
    Next
 
    Dim newDataSet As New DataTable()
    newDataSet = (pivotGrid.DataSource).Copy()
    PivotGrid1.DataSource = newDataSet
    PivotGrid1.DataMember = pivotGrid.DataMember
 
End Sub


Congratulations Telerik Team!
0
Dimitar
Telerik team
answered on 16 Jan 2015, 12:05 PM
Hello Tiago,

Thank you for sharing the Visual Basic code. I would just mention that for conversion purposes one can use our free online converter: http://converter.telerik.com
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tiago
Top achievements
Rank 1
answered on 16 Jan 2015, 01:20 PM
Hallo, Dimitar!
By the way, is possible select programmatically cells in a radPivotgrid and in this way, also, know what cells are selected ?
For example: I wish know what are the selected cells in a Pivotgrid 1 and select exactly this cells in a identical Privogrid 2. 
0
Dimitar
Telerik team
answered on 21 Jan 2015, 10:35 AM
Hi Tiago,

Thank you for contacting us.

You can iterate all cells and determine which are selected with the following code (you can select a cell as well):
var rowGroups = radPivotGrid1.PivotGridElement.GetRowGroups();
var colGroups = radPivotGrid1.PivotGridElement.GetColumnGroups();
foreach (PivotGroupNode col in colGroups)
{
    foreach (PivotGroupNode row in rowGroups)
    {
        if (row.Group != null && col.Group != null)
        {
            if (radPivotGrid1.PivotGridElement.IsCellSelected(row, col))
            {
                var Value = this.radPivotGrid1.PivotGridElement.GetAggregateValue(row.Group, col.Group, false, false);
                Debug.WriteLine("Row = {0} , Column ={1}, Value ={2}", row.Name, col.Name, Value);
            }
            // or you can select a cell like this
            radPivotGrid1.PivotGridElement.SelectCell(row, col, false, true);
             
        }
    }
}

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tiago
Top achievements
Rank 1
answered on 21 Jan 2015, 11:18 AM
Hi, Dimitar,
Thank you very much, it is was a great help

Congratulations Telerik Team!
0
Dimitar
Telerik team
answered on 21 Jan 2015, 02:18 PM
Hi Tiago,

Thank you for writing back.

I am glad that you have found our service useful. Do not hesitate to contact us if you have other questions.
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Documentation
Asked by
Tiago
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Tiago
Top achievements
Rank 1
Share this question
or