using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

public partial class RadPivotGridWithConfigurationPanel : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        
    }


    public DataTable GetDataTable()
    {

        DataTable table = new DataTable();
        table.Columns.Add("PlaneType");
        table.Columns.Add("PlaneModel");
        table.Columns.Add("Country");
        table.Columns.Add("City");
        table.Columns.Add("Passengers", typeof(Decimal));
        table.Columns.Add("Cargo", typeof(Decimal));

        table.Rows.Add("Airbus", "A320", "UK", "London", 10 * 1, 1 * 1);
        table.Rows.Add("Airbus", "A320", "UK", "London", 20.76 * 1, 2 * 1);
        table.Rows.Add("Airbus", "A320", "UK", "Manchester", 30.8 * 1, 3 * 1);
        table.Rows.Add("Airbus", "A320", "UK", "Manchester", 40.9 * 1, 4 * 1);
        table.Rows.Add("Airbus", "A320", "Germany", "Berlin", 50 * 1, 5 * 1);
        table.Rows.Add("Airbus", "A320", "Germany", "Berlin", 60.133348478 * 1, 2 * 3.90797976963);
        table.Rows.Add("Airbus", "A320", "Germany", "Munchen", 70 * 1, 7 * 1);
        table.Rows.Add("Airbus", "A320", "Germany", "Munchen", 80 * 1, 8 * 1);

        table.Rows.Add("Airbus", "A340", "UK", "London", 10 * 2.345973937895, 1 * 2);
        table.Rows.Add("Airbus", "A340", "UK", "London", 20 * 2, 2 * 2);
        table.Rows.Add("Airbus", "A340", "UK", "Manchester", 30 * 2, 3 * 2);
        table.Rows.Add("Airbus", "A340", "UK", "Manchester", 40 * 2, 4 * 2);
        table.Rows.Add("Airbus", "A340", "Germany", "Berlin", 50 * 2, 5 * 2);
        table.Rows.Add("Airbus", "A340", "Germany", "Berlin", 60 * 2, 6 * 2);
        table.Rows.Add("Airbus", "A340", "Germany", "Munchen", 70 * 2, 7 * 2);
        table.Rows.Add("Airbus", "A340", "Germany", "Munchen", 80 * 2, 8 * 2);

        table.Rows.Add("Boeing", "737", "UK", "London", 10 * 3, 1 * 3);
        table.Rows.Add("Boeing", "737", "UK", "London", 20 * 3, 2 * 3);
        table.Rows.Add("Boeing", "737", "UK", "Manchester", 30 * 3, 3 * 3);
        table.Rows.Add("Boeing", "737", "UK", "Manchester", 40 * 3, 4 * 3);
        table.Rows.Add("Boeing", "737", "Germany", "Berlin", 50 * 3, 5 * 3);
        table.Rows.Add("Boeing", "737", "Germany", "Berlin", 60 * 3, 6 * 3);
        table.Rows.Add("Boeing", "737", "Germany", "Munchen", 70 * 3, 7 * 3);
        table.Rows.Add("Boeing", "737", "Germany", "Munchen", 80 * 3, 8 * 3);

        table.Rows.Add("Boeing", "747", "UK", "London", 10 * 4, 1 * 4);
        table.Rows.Add("Boeing", "747", "UK", "London", 20 * 4, 2 * 4);
        table.Rows.Add("Boeing", "747", "UK", "Manchester", 30 * 4, 3 * 4);
        table.Rows.Add("Boeing", "747", "UK", "Manchester", 40 * 4, 4 * 4);
        table.Rows.Add("Boeing", "747", "Germany", "Berlin", 50 * 4, 5 * 4);
        table.Rows.Add("Boeing", "747", "Germany", "Berlin", 60 * 4, 6 * 4);
        table.Rows.Add("Boeing", "747", "Germany", "Munchen", 70 * 4, 7 * 4);
        table.Rows.Add("Boeing", "747", "Germany", "Munchen", 80 * 4, 8 * 4);

        table.Rows.Add("Embraer", "E190", "UK", "London", 10 * 3, 1 * 5);
        table.Rows.Add("Embraer", "E190", "UK", "London", 20 * 3, 2 * 5);
        table.Rows.Add("Embraer", "E190", "UK", "Manchester", 30 * 3, 3 * 5);
        table.Rows.Add("Embraer", "E190", "UK", "Manchester", 40 * 3, 4 * 5);
        table.Rows.Add("Embraer", "E190", "Germany", "Berlin", 50 * 3, 5 * 5);
        table.Rows.Add("Embraer", "E190", "Germany", "Berlin", 60 * 3, 6 * 5);
        table.Rows.Add("Embraer", "E190", "Germany", "Munchen", 70 * 3, 7 * 5);
        table.Rows.Add("Embraer", "E190", "Germany", "Munchen", 80 * 3, 8 * 5);

        table.Rows.Add("Embraer", "E170", "UK", "London", 10 * 4, 1 * 6);
        table.Rows.Add("Embraer", "E170", "UK", "London", 20 * 4, 2 * 6);
        table.Rows.Add("Embraer", "E170", "UK", "Manchester", 30 * 4, 3 * 6);
        table.Rows.Add("Embraer", "E170", "UK", "Manchester", 40 * 4, 4 * 6);
        table.Rows.Add("Embraer", "E170", "Germany", "Berlin", 50 * 4, 5 * 6);
        table.Rows.Add("Embraer", "E170", "Germany", "Berlin", 60 * 4, 6 * 6);
        table.Rows.Add("Embraer", "E170", "Germany", "Munchen", 70 * 4, 7 * 6);
        table.Rows.Add("Embraer", "E170", "Germany", "Munchen", 80 * 4, 8 * 6);

        return table;
    }
    protected void RadPivotGrid1_NeedDataSource(object sender, Telerik.Web.UI.PivotGridNeedDataSourceEventArgs e)
    {
        this.RadPivotGrid1.DataSource = this.GetDataTable();
    }
    protected void btn1_Click(object sender, EventArgs e)
    {
        RadPivotGrid1.CollapseAllFieldGroups(RadPivotGrid1.Fields["PlaneType"] as PivotGridRowField, true);
        RadPivotGrid1.Rebind();
    }
}