Duplicate a RadPivotgrid Data

9 posts, 0 answers
  1. Tiago
    Tiago avatar
    10 posts
    Member since:
    Feb 2014

    Posted 13 Jan 2015 Link to this post

    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

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 15 Jan 2015 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Tiago
    Tiago avatar
    10 posts
    Member since:
    Feb 2014

    Posted 15 Jan 2015 in reply to Dimitar Link to this post

    Thank you very much for the excellent support provided , really helped - me.
  5. Tiago
    Tiago avatar
    10 posts
    Member since:
    Feb 2014

    Posted 16 Jan 2015 Link to this post

    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!
  6. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 16 Jan 2015 Link to this post

    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.

     
  7. Tiago
    Tiago avatar
    10 posts
    Member since:
    Feb 2014

    Posted 16 Jan 2015 in reply to Dimitar Link to this post

    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. 
  8. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 21 Jan 2015 Link to this post

    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.

     
  9. Tiago
    Tiago avatar
    10 posts
    Member since:
    Feb 2014

    Posted 21 Jan 2015 in reply to Dimitar Link to this post

    Hi, Dimitar,
    Thank you very much, it is was a great help

    Congratulations Telerik Team!
  10. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 21 Jan 2015 Link to this post

    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.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready