コード例 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack && !IsCallback)
     {
         ASPxPivotGrid1.DataBind();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            ds.ReadXml(Server.MapPath(@"~/App_Data/CustomerReports.xml"));
            ASPxPivotGrid1.DataSource = ds.Tables[0];
            ASPxPivotGrid1.DataBind();
        }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ASPxRadioButtonList1.SelectedItem != null)
     {
         mode = Convert.ToString(ASPxRadioButtonList1.SelectedItem.Value);
         ASPxPivotGrid1.DataBind();
     }
 }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // Creates a new collection of OLAP member properties.
     fieldProduct.AutoPopulatedProperties = new string[] { "Color", "List Price" };
     ASPxPivotGrid1.DataBind();
     // Sets a field's sort mode to Custom to raise the CustomServerModeSort event.
     fieldProduct.SortMode = PivotSortMode.Custom;
 }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string connStr = "Data Source=(local);Initial Catalog=Northwind;Integrated Security=true";
            string query   = "SELECT TOP 30 e.LastName AS Employee, o.ShipCountry, " +
                             "o.ShipCity, o.Freight, o.OrderDate FROM Orders o " +
                             "INNER JOIN Employees e ON o.EmployeeID = e.EmployeeID " +
                             "ORDER BY Freight DESC";
            SqlDataAdapter adapter   = new SqlDataAdapter(query, connStr);
            DataTable      dataTable = new DataTable();

            adapter.Fill(dataTable);

            if (!IsPostBack && !IsCallback)
            {
                // create fields
                PivotGridField fieldEmployee = new PivotGridField();
                fieldEmployee.ID        = "fieldEmployee";
                fieldEmployee.FieldName = "Employee";
                fieldEmployee.Area      = DevExpress.XtraPivotGrid.PivotArea.ColumnArea;
                ASPxPivotGrid1.Fields.Add(fieldEmployee);

                PivotGridField fieldCountry = new PivotGridField();
                fieldCountry.ID        = "fieldCountry";
                fieldCountry.FieldName = "ShipCountry";
                fieldCountry.Area      = DevExpress.XtraPivotGrid.PivotArea.RowArea;
                ASPxPivotGrid1.Fields.Add(fieldCountry);

                PivotGridField fieldCity = new PivotGridField();
                fieldCity.ID        = "fieldCity";
                fieldCity.FieldName = "ShipCity";
                fieldCity.Area      = DevExpress.XtraPivotGrid.PivotArea.RowArea;
                ASPxPivotGrid1.Fields.Add(fieldCity);

                PivotGridField fieldFreight = new PivotGridField();
                fieldFreight.ID        = "fieldFreight";
                fieldFreight.FieldName = "Freight";
                fieldFreight.Area      = DevExpress.XtraPivotGrid.PivotArea.DataArea;
                ASPxPivotGrid1.Fields.Add(fieldFreight);

                PivotGridField fieldOrderDate = new PivotGridField();
                fieldOrderDate.ID        = "fieldOrderDate";
                fieldOrderDate.FieldName = "OrderDate";
                fieldOrderDate.Area      = DevExpress.XtraPivotGrid.PivotArea.FilterArea;
                fieldOrderDate.ValueFormat.FormatType   = DevExpress.Utils.FormatType.DateTime;
                fieldOrderDate.ValueFormat.FormatString = "MMM yyyy";
                fieldOrderDate.GroupInterval            = DevExpress.XtraPivotGrid.PivotGroupInterval.DateMonth;
                ASPxPivotGrid1.Fields.Add(fieldOrderDate);
            }

            ASPxPivotGrid1.DataSource = dataTable;
            ASPxPivotGrid1.DataBind();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         if (Request.Params["__EVENTTARGET"].Contains(ASPxPivotGrid1.ID) && Request.Params["__EVENTARGUMENT"].StartsWith("Data"))
         {
             string[] args = Request.Params["__EVENTARGUMENT"].Split('|');
             if (args.Length == 3)
             {
                 if (!ASPxPivotGrid1.IsDataBound)
                 {
                     ASPxPivotGrid1.DataBind();
                 }
                 Session["DS"] = Convert(ASPxPivotGrid1.CreateDrillDownDataSource(int.Parse(args[1]), int.Parse(args[2])));
                 Response.Redirect("DetailPage.aspx");
             }
         }
     }
 }
コード例 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ASPxPivotGrid1.DataSource = ManualDataSet.CreateData().Tables[0];
        ASPxPivotGrid1.DataBind();

        if (!IsPostBack)
        {
            Session["selectedRowIndex"] = 0;
            Session["selectedColIndex"] = 0;

            ASPxPivotGrid1.RetrieveFields();
            ASPxPivotGrid1.Fields["MyData"].Area     = DevExpress.XtraPivotGrid.PivotArea.DataArea;
            ASPxPivotGrid1.Fields["MyRow"].Area      = DevExpress.XtraPivotGrid.PivotArea.RowArea;
            ASPxPivotGrid1.Fields["MyDateTime"].Area = DevExpress.XtraPivotGrid.PivotArea.ColumnArea;

            ASPxPivotGrid1.Fields["MyDateTime"].ValueFormat.FormatType         = DevExpress.Utils.FormatType.DateTime;
            ASPxPivotGrid1.Fields["MyDateTime"].ValueFormat.FormatString       = "d";
            ((XYDiagram)WebChartControl1.Diagram).AxisX.DateTimeOptions.Format = DateTimeFormat.ShortDate;
        }

        PrepareChartData();
        FillChart();
    }
コード例 #8
0
        private void LoadData(List <Dictionary <string, string> > filters)
        {
            string sql = string.Format("select * from S_UI_Pivot where Code='{0}'", Request["TmplCode"]);

            if (isFreePivot)//自由透视表
            {
                sql = string.Format("select S_UI_FreePivotInstance.*,ConnName from S_UI_FreePivotInstance join S_UI_FreePivot on S_UI_FreePivot.ID=FreePivotID where S_UI_FreePivotInstance.ID='{0}'", Request["ID"]);
            }

            SQLHelper baseSqlHelper = SQLHelper.CreateSqlHelper("Base");
            var       dt            = baseSqlHelper.ExecuteDataTable(sql);

            if (dt.Rows.Count == 0) //找不到定义
            {
                return;
            }
            var row       = dt.Rows[0];
            var sqlHelper = SQLHelper.CreateSqlHelper(row["ConnName"].ToString());

            sql = row["SQL"].ToString();

            string str = "";

            foreach (var item in filters)
            {
                string value     = item.Keys.Contains("FieldValue") ? item["FieldValue"].Replace("'", "") : "";
                string queryType = item.Keys.Contains("QueryType") && !string.IsNullOrWhiteSpace(item["QueryType"]) ? item["QueryType"] : "in";
                if (!string.IsNullOrEmpty(value))
                {
                    if (queryType == "in")
                    {
                        str += string.Format(" and {0} in('{1}')", item["FieldName"], value.Replace(",", "','"));
                    }
                    else if (queryType == "like")
                    {
                        str += string.Format(" and {0} like '%{1}%'", item["FieldName"], value);
                    }
                    else if (queryType.StartsWith("between"))
                    {
                        if (!value.Contains(','))
                        {
                            value += ",";
                        }
                        string   v1 = value.Split(',')[0];
                        string   v2 = value.Split(',')[1];
                        DateTime t1 = new DateTime(1900, 1, 1);
                        DateTime t2 = new DateTime(9999, 12, 31);
                        if (DateTime.TryParse(v1, out t1) || DateTime.TryParse(v2, out t2))
                        {
                            str += string.Format(" and {0} between '{1}' and '{2} 23:59:59'", item["FieldName"], t1.ToString("yyyy-MM-dd"), t2.ToString("yyyy-MM-dd"));
                        }
                    }
                    else
                    {
                        str += string.Format(" and {0} {1} '{2}'", item["FieldName"], item["QueryType"], value);
                    }
                }
            }
            if (Config.Constant.IsOracleDb)
            {
                sql = string.Format("select * from ({0}) tb where 1=1 {1}", sql, str);
            }
            else
            {
                sql = string.Format("select * from ({0}) as tb where 1=1 {1}", sql, str);
            }


            DataTable result = sqlHelper.ExecuteDataTable(sql);

            enumHtml = "<script type='text/javascript'>";


            List <Dictionary <string, string> > fields = new List <Dictionary <string, string> >();

            fields.AddRange(userRowItems);
            fields.AddRange(userColumnItems);
            fields.AddRange(userDataItems);
            fields.AddRange(userFilterItems);
            foreach (var item in fields)
            {
                if (!item.ContainsKey("Enum"))
                {
                    continue;
                }

                if (string.IsNullOrEmpty(item["Enum"]))
                {
                    continue;
                }

                string strEnum = "";
                if (item["Enum"].StartsWith("["))
                {
                    strEnum = item["Enum"];
                }
                else
                {
                    dt = baseSqlHelper.ExecuteDataTable(
                        string.Format("select S_M_EnumItem.Code as value,S_M_EnumItem.Name as text from S_M_EnumItem join S_M_EnumDef on S_M_EnumDef.ID=EnumDefID where S_M_EnumDef.Code='{0}'", item["Enum"]));
                    strEnum = JsonHelper.ToJson(dt);
                }

                enumHtml += string.Format(@"
var enum_{0} = {1};
", item["FieldName"], strEnum);


                if (item["Enum"] == "[]")
                {
                    continue;
                }

                var enumList = JsonHelper.ToList(strEnum);

                result.Columns.Add(item["FieldName"] + "_");
                foreach (DataRow row1 in result.Rows)
                {
                    row1[item["FieldName"] + "_"] = GetEnumText(enumList, row1[item["FieldName"]].ToString());
                }
                result.Columns.Remove(item["FieldName"]);
                result.Columns[item["FieldName"] + "_"].ColumnName = item["FieldName"];
            }

            enumHtml += @"
</script>";

            ASPxPivotGrid1.DataSource = result;
            ASPxPivotGrid1.DataBind();
        }
コード例 #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ASPxPivotGrid1.DataSource = CreatePivotData();
     ASPxPivotGrid1.DataBind();
 }