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

Create report based on pivot settings

5 Answers 129 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Stefania
Top achievements
Rank 2
Stefania asked on 20 May 2014, 03:11 PM
Hi,
I have a form with pivotgrid and 2 htmlchart syncronized with the same data.
Pivotgrid's columns, rows and aggregates are customizable by the users.
I need to produce a report with the same pivotgrid layout/data and charts.

Is it possible?

I was thinking about to save session with RadPersistenceManager and use it in same way to create the report..

My real issue is to recreate the same pivotgrid layout..

5 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 23 May 2014, 11:30 AM
Hello Stefania,

Are you using a OLAP data source? If that is correct then you have to save the current selected pivot grid fields and then create their structure dynamically on Page_Load event as demonstrated in the following live example. Otherwise could you please provide more details how your pivot grid is configured and bind? 

Regards,
Kostadin
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
Stefania
Top achievements
Rank 2
answered on 23 May 2014, 12:56 PM
Hi Kostadin,
thanks for your reply.
I don't see the demo..

I'm not using OLAP datasource

this is my Pivot
<telerik:RadPivotGrid ID="PivotGrid1" runat="server" OnPreRender="RadPivotGrid1_PreRender"
                                        Width="100%" AllowSorting="True" EmptyValue="0" OnCellDataBound="RadPivotGrid1_CellDataBound"
                                        ShowFilterHeaderZone="False" ShowColumnHeaderZone="False" EnableZoneContextMenu="True"
                                       EnableConfigurationPanel="True" Culture="it-IT" meta:resourcekey="PivotGrid1Resource1">
                                    </telerik:RadPivotGrid>

C#
protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
 
        PivotGrid1.ContextMenu.PreRender += ContextMenu_PreRender;
        PivotGrid1.NeedDataSource +=new EventHandler<PivotGridNeedDataSourceEventArgs>(PivotGrid1_NeedDataSource);
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
 
        if (!IsPostBack)
        {           
            CreateStandardPivotLayout();           
        }
    }
 
    private void ContextMenu_PreRender(object sender, EventArgs e)
    {
        PivotGrid1.ContextMenu.FindItemByValue("Hide").Visible = false;
    }
 
    private void CreateStandardPivotLayout()
    {
        PivotGridRowField rowField = new PivotGridRowField();
        PivotGrid1.Fields.Add(rowField);
        rowField.DataField = "CdcCode";
        rowField.UniqueName = "CdcCode";
        rowField.Caption = GetGlobalResourceObject("GlobalText", "CdcCode").ToString();
 
        PivotGridColumnField columnField = new PivotGridColumnField();
        PivotGrid1.Fields.Add(columnField);
        columnField.DataField = "AlarmLevelDescription";
        columnField.UniqueName = "AlarmLevelDescription";
        columnField.Caption = GetGlobalResourceObject("GlobalText", "AlarmLevelDescription").ToString();
 
        PivotGridAggregateField aggregateField = new PivotGridAggregateField();
        PivotGrid1.Fields.Add(aggregateField);
        aggregateField.DataField = "AlarmLevelDescription";
        aggregateField.Caption = GetGlobalResourceObject("GlobalText", "AlarmLevelDescription").ToString();
        aggregateField.UniqueName = "AlarmLevelDescription_Aggregate";
        aggregateField.DataFormatString = "{0:N0}";
        aggregateField.TotalFormatString = "{0:N0}";
        aggregateField.Aggregate = PivotGridAggregate.Count;
        aggregateField.SortOrder = PivotGridSortOrder.Ascending;
        aggregateField.TotalFormat.Axis = PivotGridAxis.Rows;
        aggregateField.TotalFormat.Level = 0;
        aggregateField.TotalFormat.SortOrder = PivotGridSortOrder.Ascending;
        aggregateField.TotalFormat.TotalFunction = PivotGridTotalFunction.NoCalculation;   
    }

protected void PivotGrid1_NeedDataSource(object sender, PivotGridNeedDataSourceEventArgs e)
    {
        if (RadTreeView1.CheckedNodes.Count == 0 || !DateFromPicker.SelectedDate.HasValue || !DateToPicker.SelectedDate.HasValue)
        {
            RadNotification1.Show(GetGlobalResourceObject("GlobalText", "ChooseFilter").ToString());
            return;
        }
 
        LoadPivotGrid();
    }
 
    private void LoadPivotGrid()
    {
        var nodes = RadTreeView1.CheckedNodes;
        m_CompaniesFilter = new List<string>();
        m_CountriesFilter = new List<int>();
        m_SitesFilter = new List<int>();
        m_CdcsFilter = new List<int>();
 
        nodes.ToList().Where(p=>p.Level == 0).ToList().ForEach(p => m_CompaniesFilter.Add(p.Value));
        nodes.ToList().Where(p => p.Level == 1).ToList().ForEach(p => m_CountriesFilter.Add(Convert.ToInt32(p.Value.Replace("P_",string.Empty))));
        nodes.ToList().Where(p => p.Level == 2).ToList().ForEach(p => m_SitesFilter.Add(Convert.ToInt32(p.Value.Replace("S_", string.Empty))));
        nodes.ToList().Where(p => p.Level == 3).ToList().ForEach(p => m_CdcsFilter.Add(Convert.ToInt32(p.Value.Replace("C_", string.Empty))));
 
        m_ReportList = m_ReportHelper.GetPivotData(m_CompaniesFilter, m_CountriesFilter, m_SitesFilter, m_CdcsFilter, DateFromPicker.SelectedDate.Value, DateToPicker.SelectedDate.Value, m_UserId);
 
        PivotGrid1.DataSource = m_ReportList;
    }
0
Kostadin
Telerik team
answered on 28 May 2014, 06:41 AM
Hello Stefania,

Could you please let me know how the user customize the columns, rows and aggregates fields? From the provided code snippet I noticed that you have initially declare them in the code behind. If you want to declare a different fields for the different users then I would recommend to create the entire PivotGrid structure on Page_Init event handler as described in the following help article.

Regards,
Kostadin
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
Stefania
Top achievements
Rank 2
answered on 28 May 2014, 07:18 AM
Hi Kostadin,
users can customize the columns, rows and aggregates fields from the fields window.
From code-behind I just need to create the first pivot structure after that user can customize it from the fields window (add/remove columns, rows and aggregations).
After the customizations he should be print a report with the final result.

For now my workaround is to print directly the window, hiding what I don't want to print.
just like this:
http://www.telerik.com/help/aspnet-ajax/htmlchart-print-the-chart.html
Obviously it's not exacly what I wanted but it works
0
Kostadin
Telerik team
answered on 30 May 2014, 11:35 AM
Hello Stefania,

You could use the PersistenceFramework to recreate the PivotGrid but I am afraid you could not export it together with the charts. You could check out the following live example which demonstrates how to persist the PivotGrid state.

Regards,
Kostadin
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
PivotGrid
Asked by
Stefania
Top achievements
Rank 2
Answers by
Kostadin
Telerik team
Stefania
Top achievements
Rank 2
Share this question
or