Example #1
0
        public static void Export(this ASPxPivotGrid ASPxPivotGrid1, ASPxPivotGridExporter ASPxPivotGridExporter1, string fileName, bool saveAs)
        {
            foreach (PivotGridField field in ASPxPivotGrid1.Fields)
            {
                if (field.ValueFormat != null && !string.IsNullOrEmpty(field.ValueFormat.FormatString))
                {
                    field.UseNativeFormat = DefaultBoolean.True;
                }
            }

            ASPxPivotGridExporter1.OptionsPrint.PrintHeadersOnEveryPage = true;
            ASPxPivotGridExporter1.OptionsPrint.MergeColumnFieldValues  = true;
            ASPxPivotGridExporter1.OptionsPrint.MergeRowFieldValues     = true;

            ASPxPivotGridExporter1.OptionsPrint.PrintFilterHeaders = DefaultBoolean.True;
            ASPxPivotGridExporter1.OptionsPrint.PrintColumnHeaders = DefaultBoolean.True;
            ASPxPivotGridExporter1.OptionsPrint.PrintRowHeaders    = DefaultBoolean.True;
            ASPxPivotGridExporter1.OptionsPrint.PrintDataHeaders   = DefaultBoolean.True;

            XlsxExportOptionsEx options;

            options = new XlsxExportOptionsEx()
            {
                ExportType                  = ExportType.DataAware,
                AllowGrouping               = DefaultBoolean.True,
                TextExportMode              = TextExportMode.Text,
                AllowFixedColumns           = DefaultBoolean.True,
                AllowFixedColumnHeaderPanel = DefaultBoolean.True,
                //RawDataMode = exportRawData.Checked
            };

            ASPxPivotGridExporter1.ExportXlsxToResponse(HttpUtility.UrlEncode(fileName), options, saveAs);
        }
Example #2
0
        /// <summary>
        /// Thử kết nối đến database Olap
        /// </summary>
        /// <param name="pivot">Lưới hiển thị dữ liệu</param>
        /// <returns>Trả về chuỗi lỗi nếu không kết nối được, ngược lại trả về null</returns>
        public static string TryConnect(ASPxPivotGrid pivotGrid, string cnnsName, string cubeName)
        {
            if (ConfigurationManager.ConnectionStrings.Count > 0 && ConfigurationManager.ConnectionStrings[cnnsName] != null)
            {
                string cnns = string.Format(ConfigurationManager.ConnectionStrings[cnnsName].ConnectionString, cubeName);
                pivotGrid.OLAPConnectionString = cnns;
            }
            else
            {
                StringBuilder res = new StringBuilder();
                res.Append("<br/><pre>").Append(string.Format("Kết nối chưa được thiết lập cho cube '{0}', vui lòng kiểm tra chuỗi kết nối trong Web.Config", cubeName)).Append("</pre>");
                return(res.ToString());
            }

            if (!OLAPMetaGetter.IsProviderAvailable)
            {
                pivotGrid.OLAPConnectionString = null;
                return(NoProviderErrorString);
            }

            try
            {
                pivotGrid.DataBind();
            }
            catch (OLAPConnectionException exception)
            {
                pivotGrid.OLAPConnectionString = null;
                StringBuilder res = new StringBuilder(ExceptionErrorString);
                res.Append("<br/><pre>").Append(exception.ToString()).Append("</pre>");
                return(res.ToString());
            }
            return(null);
        }
        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);

            // Initializes a data source.
            ds = new AccessDataSource("~/nwind.mdb", "SELECT [CategoryName]," +
                "[ProductName], [ProductSales], [ShippedDate] FROM [ProductReports]");

            // Initializes ASPxPivotGrid.
            ASPxPivotGrid1 = new ASPxPivotGrid();

            // Binds ASPxPivotGrid to the data source.
            ASPxPivotGrid1.DataSource = ds;
            
            // Places the Pivot Grid onto a page.
            form1.Controls.Add(ASPxPivotGrid1);

            if (ASPxPivotGrid1.Fields.Count != 0) 
                return;

            // Creates pivot grid fields for all data source fields.
            ASPxPivotGrid1.RetrieveFields();

            // Locates the pivot grid fields in appropriate areas.
            ASPxPivotGrid1.Fields["CategoryName"].Area = PivotArea.RowArea;
            ASPxPivotGrid1.Fields["ProductName"].Area = PivotArea.RowArea;
            ASPxPivotGrid1.Fields["ShippedDate"].Area = PivotArea.ColumnArea;
            ASPxPivotGrid1.Fields["ProductSales"].Area = PivotArea.DataArea;

            ASPxPivotGrid1.Fields["ShippedDate"].GroupInterval = PivotGroupInterval.DateYear;
        }
        /// <summary>
        /// Thử kết nối đến database Olap
        /// </summary>
        /// <param name="pivot">Lưới hiển thị dữ liệu</param>
        /// <returns>Trả về chuỗi lỗi nếu không kết nối được, ngược lại trả về null</returns>
        public static string TryConnect(ASPxPivotGrid pivotGrid, string cnnsName, string cubeName)
        {
            if (ConfigurationManager.ConnectionStrings.Count > 0 && ConfigurationManager.ConnectionStrings[cnnsName] != null)
            {
                string cnns = string.Format(ConfigurationManager.ConnectionStrings[cnnsName].ConnectionString, cubeName);
                pivotGrid.OLAPConnectionString = cnns;
            }
            else
            {
                StringBuilder res = new StringBuilder();
                res.Append("<br/><pre>").Append(string.Format("Kết nối chưa được thiết lập cho cube '{0}', vui lòng kiểm tra chuỗi kết nối trong Web.Config", cubeName)).Append("</pre>");
                return res.ToString();
            }

            if (!OLAPMetaGetter.IsProviderAvailable)
            {
                pivotGrid.OLAPConnectionString = null;
                return NoProviderErrorString;
            }

            try
            {
                pivotGrid.DataBind();
            }
            catch (OLAPConnectionException exception)
            {
                pivotGrid.OLAPConnectionString = null;
                StringBuilder res = new StringBuilder(ExceptionErrorString);
                res.Append("<br/><pre>").Append(exception.ToString()).Append("</pre>");
                return res.ToString();
            }
            return null;
        }
    protected void ASPxPivotGrid1_FieldAreaChanged(object sender, DevExpress.Web.ASPxPivotGrid.PivotFieldEventArgs e)
    {
        ASPxPivotGrid pivot = (ASPxPivotGrid)sender;

        pivot.OptionsChartDataSource.ProvideColumnGrandTotals = pivot.Fields.GetVisibleFieldCount(DevExpress.XtraPivotGrid.PivotArea.ColumnArea) == 0 ? true : false;
        pivot.OptionsChartDataSource.ProvideRowGrandTotals    = pivot.Fields.GetVisibleFieldCount(DevExpress.XtraPivotGrid.PivotArea.RowArea) == 0 ? true : false;
    }
    protected void ASPxPivotGrid1_CustomSummary(object sender, PivotGridCustomSummaryEventArgs e)
    {
        if (ReferenceEquals(e.DataField, fieldProductAmount))
        {
            // This is a Grand Total cell.
            if (ReferenceEquals(e.ColumnField, null) || ReferenceEquals(e.RowField, null))
            {
                e.CustomValue = "Grand Total";
                return;
            }
            ASPxPivotGrid pivot                = sender as ASPxPivotGrid;
            int           lastRowFieldIndex    = pivot.Fields.GetVisibleFieldCount(PivotArea.RowArea) - 1;
            int           lastColumnFieldIndex = pivot.Fields.GetVisibleFieldCount(PivotArea.ColumnArea) - 1;

            // This is an ordinary cell.
            if (e.RowField.AreaIndex == lastRowFieldIndex && e.ColumnField.AreaIndex == lastColumnFieldIndex)
            {
                e.CustomValue = e.SummaryValue.Average;
            }
            // This is a Total cell.
            else
            {
                e.CustomValue = "Total";
            }
        }
    }
Example #7
0
 public static OlapColumnInfo GetHeaderPivotInfo(ASPxPivotGrid pivot, string columnName)
 {
     try
     {
         for (int i = 0; i < pivot.Fields.Count; i++)
         {
             var arrSource = pivot.Fields[i].OLAPDrillDownColumnName.ToLower().Split('.');
             var arrDest   = columnName.ToLower().Split('.');
             if (arrDest != null && arrSource != null)
             {
                 var olapcolName         = arrSource.LastOrDefault();
                 var colName             = arrDest.LastOrDefault();
                 var colNameNoWhiteSpace = colName.Replace(" ", "");
                 if (olapcolName.Equals(colName) ||
                     olapcolName.Equals(colNameNoWhiteSpace))
                 {
                     return(new OlapColumnInfo(pivot.Fields[i].Caption
                                               , pivot.Fields[i].CellFormat
                                               , pivot.Fields[i].Width));
                 }
             }
         }
     }
     catch
     {
         return(null);
     }
     return(null);
 }
Example #8
0
        protected void pivot_Init(object sender, EventArgs e)
        {
            ASPxPivotGrid pivot = sender as ASPxPivotGrid;

            pivot.OptionsPager.RowsPerPage                          = 30;
            pivot.OptionsPager.ColumnsPerPage                       = 40;
            pivot.OptionsPager.Position                             = System.Web.UI.WebControls.PagerPosition.Bottom;
            pivot.OptionsPager.Visible                              = false;
            pivot.OptionsView.VerticalScrollBarMode                 = ScrollBarMode.Visible;
            pivot.OptionsView.HorizontalScrollBarMode               = ScrollBarMode.Visible;
            pivot.OptionsView.VerticalScrollingMode                 = PivotScrollingMode.Virtual;
            pivot.OptionsView.HorizontalScrollingMode               = PivotScrollingMode.Virtual;
            pivot.OptionsView.ShowRowTotals                         = false;
            pivot.OptionsView.ShowColumnGrandTotals                 = false;
            pivot.OptionsView.ShowRowGrandTotals                    = false;
            pivot.OptionsView.ShowFilterSeparatorBar                = false;
            pivot.OptionsView.ShowFilterHeaders                     = false;
            pivot.OptionsView.ShowDataHeaders                       = false;
            pivot.OptionsView.ShowContextMenus                      = false;
            pivot.OptionsView.ShowColumnHeaders                     = false;
            pivot.OptionsFilter.ShowOnlyAvailableItems              = true;
            pivot.Styles.HeaderStyle.HorizontalAlign                = System.Web.UI.WebControls.HorizontalAlign.Center;
            pivot.Styles.HeaderStyle.VerticalAlign                  = System.Web.UI.WebControls.VerticalAlign.Middle;
            pivot.OptionsCustomization.AllowPrefilter               = false;
            pivot.OptionsCustomization.AllowCustomizationForm       = false;
            pivot.OptionsCustomization.AllowDrag                    = false;
            pivot.OptionsCustomization.AllowDragInCustomizationForm = false;
            pivot.OptionsCustomization.AllowSortBySummary           = false;
            pivot.OptionsCustomization.AllowSortInCustomizationForm = false;
            pivot.OptionsCustomization.AllowExpand                  = false;
            pivot.OptionsCustomization.AllowFilter                  = false;
            pivot.OptionsCustomization.AllowSort                    = false;
        }
Example #9
0
        protected void pivotMatrixSV_Init(object sender, EventArgs e)
        {
            pivot_Init(sender, e);
            ASPxPivotGrid pivot = sender as ASPxPivotGrid;

            pivot.Caption = "SUPERVISORS AUDIT MATRIX";
        }
    private static void FillDatasetColumns(ASPxPivotGrid pivot, DataTable dataTable1)
    {
        dataTable1.Columns.Add("RowFields", typeof(string));
        StringBuilder sb = new StringBuilder();
        bool          multipleDataField = pivot.GetFieldsByArea(PivotArea.DataArea).Count > 1;

        for (int i = 0; i < pivot.ColumnCount; i++)
        {
            DevExpress.Web.ASPxPivotGrid.PivotCellBaseEventArgs pcea = pivot.GetCellInfo(i, 0);
            foreach (DevExpress.Web.ASPxPivotGrid.PivotGridField field in pcea.GetColumnFields())
            {
                sb.AppendFormat("{0} | ", field.GetDisplayText(pcea.GetFieldValue(field)));//add formatting if it's necessary
            }
            if (multipleDataField)
            {
                sb.AppendFormat("{0} | ", pcea.DataField);
            }
            if (pcea.ColumnValueType == PivotGridValueType.Value)
            {
                sb.Remove(sb.Length - 3, 3);
            }
            else
            {
                sb.Append(pcea.ColumnValueType.ToString());
            }
            dataTable1.Columns.Add(sb.ToString(), typeof(object));
            sb.Clear();
        }
    }
        protected void ASPxPivotGrid1_CustomCallback(object sender, PivotGridCustomCallbackEventArgs e)
        {
            ASPxPivotGrid pivot = (ASPxPivotGrid)sender;

            pivot.JSProperties["cpAlertMessage"] = null;
            string[] parameters = e.Parameters.Split(new char[] { '|' });
            if (parameters.Length == 5 && parameters[0] == "MenuItemClick")
            {
                if (parameters[1] == "hideValue")
                {
                    bool isColumn = parameters[4] == "ColumnArea";
                    PivotFieldValueEventArgs fieldValueInfo = pivot.GetFieldValueInfo(isColumn, Convert.ToInt32(parameters[3]));
                    if (isColumn)
                    {
                        pivot.JSProperties["cpAlertMessage"] = string.Format("Cannot hide the {0} column", fieldValueInfo.Value);
                    }
                    else
                    {
                        if (fieldValueInfo.Field != null)
                        {
                            fieldValueInfo.Field.FilterValues.Add(fieldValueInfo.Value);
                        }
                    }
                }
            }
        }
Example #12
0
    protected void AddPivot(ASPxPanel panel, DataTable dtvars, int mymeasureid, Datadictionary dict)
    {
        ASPxPivotGrid pivot = new ASPxPivotGrid();

        pivot.ID         = mymeasureid.ToString();
        pivot.DataSource = dtvars;
        pivot.DataBind();
        pivot.RetrieveFields();

        pivot.OptionsPager.RowsPerPage         = 50;
        pivot.OptionsCustomization.AllowExpand = false;

        pivot.Fields["varnum"].Area        = PivotArea.RowArea;
        pivot.Fields["variablelabel"].Area = PivotArea.RowArea;

        pivot.Fields["varnum"].AreaIndex        = 0;
        pivot.Fields["variablelabel"].AreaIndex = 1;

        //pivot.Fields["ord_pos"].Visible = false;

        pivot.Fields["timepoint_text"].Area      = PivotArea.ColumnArea;
        pivot.Fields["timepoint_text"].AreaIndex = 0;



        if (mymeasureid == 4911 | mymeasureid == 4912)
        {
            pivot.Fields["studymeasname2"].Area      = PivotArea.ColumnArea;
            pivot.Fields["studymeasname2"].AreaIndex = 1;
        }
        pivot.Fields["value"].Area = PivotArea.DataArea;

        pivot.Fields["value"].SummaryType = DevExpress.Data.PivotGrid.PivotSummaryType.Min;

        pivot.Fields["timepoint_text"].TotalsVisibility = PivotTotalsVisibility.None;
        pivot.Fields["varnum"].TotalsVisibility         = PivotTotalsVisibility.None;
        pivot.Fields["id"].TotalsVisibility             = PivotTotalsVisibility.None;
        pivot.Fields["value"].TotalsVisibility          = PivotTotalsVisibility.None;

        pivot.OptionsView.ShowColumnGrandTotals = false;
        pivot.OptionsView.ShowRowGrandTotals    = false;

        pivot.OptionsView.ShowColumnHeaders = false;
        pivot.OptionsView.ShowRowHeaders    = false;
        pivot.OptionsView.ShowDataHeaders   = false;
        pivot.OptionsView.ShowFilterHeaders = false;

        ASPxLabel lbl = new ASPxLabel();

        lbl.EncodeHtml = false;
        lbl.Text       = String.Format("<br/><b>{0}</b>", dict.measname);
        lbl.Font.Size  = 14;
        panel.Controls.Add(lbl);
        panel.Controls.Add(pivot);
    }
    public static XtraReport GenerateReport(ASPxPivotGrid pivot, ReportGeneratorType kind, int columnWidth, bool repeatRowHeader)
    {
        XtraReport rep = new XtraReport();

        rep.DataSource = FillDataset(pivot);
        rep.DataMember = ((DataSet)rep.DataSource).Tables[0].TableName;
        InitBands(rep);
        InitStyles(rep);
        InitDetailsBasedonXRTable(rep, kind, columnWidth, repeatRowHeader);
        return(rep);
    }
Example #14
0
 void SyncPivots(ASPxPivotGrid source, ASPxPivotGrid visiblePivot)
 {
     source.BeginUpdate();
     foreach (PivotGridField visibleField in visiblePivot.Fields)
     {
         PivotGridField sourceField = (PivotGridField)source.Fields.GetFieldByName(visibleField.ID + "_Source");
         SyncFields(sourceField, visibleField);
     }
     source.EndUpdate();
     source.ExpandAll();
 }
Example #15
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            var pgEditor = ((ListView)View).Editor as ASPxPivotGridListEditor;

            if (pgEditor != null)
            {
                _PivotGridControl = (ASPxPivotGrid)pgEditor.PivotGridControl;
                _PivotGridControl.BeginRefresh += _PivotGridControl_BeginRefresh;
            }
        }
Example #16
0
        public static void InitSettings(this ASPxPivotGrid grid)
        {
            grid.OptionsPager.RowsPerPage = 500;
            grid.Theme = "Office365";
            grid.ClientSideEvents.CellClick = @"
function (s, e) {
  var tr = $(e.HtmlEvent.target).parent();
  tr.parent().find('td').css('background-color', '');
  tr.find('td').css('background-color', '#dff0d8');
}";
        }
Example #17
0
 protected void Page_Init(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(this.PivotGridID))
     {
         ASPxPivotGrid pivot = this.Parent.FindControl(PivotGridID) as ASPxPivotGrid;
         if (pivot != null)
         {
             this.PivotGrid = pivot;
         }
     }
 }
    private static List <PivotGridFieldBase> GetFieldsInArea(ASPxPivotGrid pivot, PivotArea area)
    {
        List <PivotGridFieldBase> fields = new List <PivotGridFieldBase>();

        for (int i = 0; i < pivot.Fields.Count; i++)
        {
            if (pivot.Fields[i].Area == area)
            {
                fields.Add(pivot.Fields[i]);
            }
        }
        return(fields);
    }
    public static DataSet FillDataset(ASPxPivotGrid pivot)
    {
        DataSet dataSet1 = new DataSet();

        dataSet1.DataSetName = "PivotGridColumns";
        DataTable dataTable1 = new DataTable();

        dataSet1.Tables.Add(dataTable1);
        FillDatasetColumns(pivot, dataTable1);
        FillDatasetExtracted(pivot, dataTable1);

        return(dataSet1);
    }
    List <PivotGridField> GetHiddenFields(ASPxPivotGrid pivotGrid)
    {
        List <PivotGridField> res = new List <PivotGridField>();

        for (int i = 0; i < pivotGrid.Fields.Count; i++)
        {
            if (!pivotGrid.Fields[i].Visible)
            {
                res.Add(pivotGrid.Fields[i]);
            }
        }
        return(res);
    }
Example #21
0
 void CurrentRequestWindow_PagePreRender(object sender, EventArgs e)
 {
     if (View != null)
     {
         ASPxPivotGridListEditor pivotGridListEditor = View.Editor as ASPxPivotGridListEditor;
         if (pivotGridListEditor != null)
         {
             ASPxPivotGrid pivotGrid = pivotGridListEditor.PivotGridControl;
             pivotGrid.ClientSideEvents.CellClick = String.Format("function(s, e){{{0}}}", XafCallbackManager.GetScript("ViewController1",
                                                                                                                        "e.ColumnIndex.toString() + ';' + e.RowIndex.toString()"
                                                                                                                        + " + ';' + e.ColumnValueType + ';' + e.RowValueType "));
         }
     }
 }
Example #22
0
        protected void OnPivotCustomCallback(object sender, PivotGridCustomCallbackEventArgs e)
        {
            ASPxPivotGrid pivot = (ASPxPivotGrid)sender;

            string[] args     = e.Parameters.Split('|');
            int      colIndex = int.Parse(args[1]);
            int      rowIndex = int.Parse(args[2]);

            ChangeCellValue(
                pivot.CreateDrillDownDataSource(colIndex, rowIndex),
                (decimal)pivot.GetCellValue(colIndex, rowIndex),
                decimal.Parse(args[3], NumberStyles.Currency)
                );
        }
Example #23
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();

            CallbackManager.RegisterHandler(handlerId, this);

            ASPxPivotGridListEditor pivotGridListEditor = View.Editor as ASPxPivotGridListEditor;

            if (pivotGridListEditor != null)
            {
                ASPxPivotGrid pivotGrid = pivotGridListEditor.PivotGridControl;
                string        script    = CallbackManager.GetScript(handlerId, "e.ColumnIndex + ';' + e.RowIndex");
                ClientSideEventsHelper.AssignClientHandlerSafe(pivotGrid, "CellClick", "function(s, e) {" + script + "}", "pivotGrid.CellClick");
            }
        }
Example #24
0
        private List <PivotGridFieldValuePair> GetPivotFieldValues(ASPxPivotGrid pivotGridControl, int columnIndex, int rowIndex)
        {
            var pairs = new System.Collections.Generic.List <PivotGridFieldValuePair>();

            foreach (PivotGridField field in pivotGridControl.Fields)
            {
                var fieldValue = new PivotGridFieldValuePair()
                {
                    Field = field,
                    Value = GetPivotFieldValue(pivotGridControl, field, columnIndex, rowIndex)
                };
                pairs.Add(fieldValue);
            }
            return(pairs);
        }
 public static void FillPivot(ASPxPivotGrid pivot) {
     pivot.Fields.Add(Employee, PivotArea.RowArea);
     pivot.Fields.Add(Widget, PivotArea.RowArea);
     pivot.Fields.Add(Month, PivotArea.ColumnArea).AreaIndex = 0;
     pivot.Fields.Add(RetailPrice, PivotArea.DataArea);
     pivot.Fields.Add(WholesalePrice, PivotArea.DataArea);
     pivot.Fields.Add(Quantity, PivotArea.DataArea);
     pivot.Fields.Add(Remains, PivotArea.DataArea);
     foreach (PivotGridField field in pivot.Fields) {
         field.AllowedAreas = GetAllowedArea(field.Area);
     }
     pivot.OptionsView.RowTotalsLocation = PivotRowTotalsLocation.Far;
     pivot.OptionsView.ColumnTotalsLocation = PivotTotalsLocation.Far;
     pivot.OptionsDataField.Area = PivotDataArea.ColumnArea;
     pivot.OptionsDataField.AreaIndex = 1;
 }
        protected void ASPxPivotGrid1_AfterPerformCallback(object sender, EventArgs e)
        {
            ASPxPivotGrid pivot = sender as ASPxPivotGrid;

            XmlXtraSerializer s = new XmlXtraSerializer();

            using (MemoryStream stream = new MemoryStream()) {
                s.SerializeObject(pivot, stream, "PivotGrid");
                Session["Layout"] = stream.ToArray();
            }

            using (MemoryStream collapsed = new MemoryStream()) {
                pivot.Data.SaveCollapsedStateToStream(collapsed);
                Session["CollapsedState"] = collapsed.ToArray();
            }
        }
Example #27
0
        protected override void CustomSort(IAnalysisControl analysisControl, IMemberInfo memberInfo)
        {
            ASPxPivotGrid pivotGridControl = ((AnalysisControlWeb)analysisControl).PivotGrid;

            pivotGridControl.CustomFieldSort += (sender, args) => {
                var pivotedSortAttribute = memberInfo.FindAttributes <PivotedSortAttribute>().SingleOrDefault(attribute => attribute.PropertyName == args.Field.FieldName);
                if (pivotedSortAttribute != null)
                {
                    var compareResult = GetCompareResult(pivotedSortAttribute.SortDirection,
                                                         args.GetListSourceColumnValue(args.ListSourceRowIndex1, pivotedSortAttribute.SortPropertyName),
                                                         args.GetListSourceColumnValue(args.ListSourceRowIndex2, pivotedSortAttribute.SortPropertyName));
                    args.Result  = compareResult;
                    args.Handled = true;
                }
            };
        }
Example #28
0
 void GetFieldsAndValues(ASPxPivotGrid pivotGrid, int fieldIndex, int visibleIndex, int dataIndex, PivotArea area, out PivotGridField dataField, out List <PivotGridField> fields, out List <object> values)
 {
     fields    = new List <PivotGridField>();
     values    = new List <object>();
     dataField = pivotGrid.GetFieldByArea(PivotArea.DataArea, dataIndex);
     if (fieldIndex >= 0)
     {
         var clickedField = pivotGrid.Fields[fieldIndex];
         for (int i = 0; i <= clickedField.AreaIndex; i++)
         {
             var field = pivotGrid.GetFieldByArea(area, i);
             fields.Add(field);
             object value = pivotGrid.GetFieldValue(field, visibleIndex);
             values.Add(value);
         }
     }
 }
Example #29
0
    void SetSortByColumn(ASPxPivotGrid pivotGrid, PivotArea crossArea, PivotGridField dataField, List <PivotGridField> fields, List <object> values)
    {
        pivotGrid.BeginUpdate();
        List <PivotGridField> crossFields = pivotGrid.GetFieldsByArea(crossArea);

        for (int i = 0; i < crossFields.Count; i++)
        {
            crossFields[i].SortBySummaryInfo.Field = dataField;
            crossFields[i].SortBySummaryInfo.Conditions.Clear();
            for (int j = 0; j < values.Count; j++)
            {
                crossFields[i].SortBySummaryInfo.Conditions.Add(
                    new PivotGridFieldSortCondition(fields[j], values[j]));
            }
        }
        pivotGrid.EndUpdate();
    }
    private DataTable CreateSummaryTable(ASPxPivotGrid pivotGrid, PivotGridField sourceField, PivotGridField targetField, PivotGridField valueField, object sourceFieldValue)
    {
        PivotSummaryDataSource ds = ASPxPivotGrid1.CreateSummaryDataSource();
        DataTable dt = new DataTable();

        dt.Columns.Add("SourceField", typeof(string));
        dt.Columns.Add("TargetField", typeof(string));
        dt.Columns.Add("Value", typeof(decimal));
        for (int i = 0; i < ds.RowCount; i++)
        {
            if (ds.GetValue(i, sourceField) == sourceFieldValue)
            {
                dt.Rows.Add(new object[] { ds.GetValue(i, sourceField), ds.GetValue(i, targetField), ds.GetValue(i, valueField) });
            }
        }
        return(dt);
    }
Example #31
0
    void HandleSortByColumnClick(ASPxPivotGrid pivotGrid, string[] args)
    {
        int fieldIndex      = int.Parse(args[1]),
            visibleIndex    = int.Parse(args[3]),
            dataIndex       = int.Parse(args[4]);
        bool      isColumn  = bool.Parse(args[2]);
        PivotArea area      = GetArea(isColumn),
                  crossArea = GetCrossArea(isColumn);

        PivotGridField        dataField;
        List <PivotGridField> fields;
        List <object>         values;

        GetFieldsAndValues(pivotGrid, fieldIndex, visibleIndex, dataIndex, area,
                           out dataField, out fields, out values);

        SetSortByColumn(pivotGrid, crossArea, dataField, fields, values);
    }
Example #32
0
    public static void BindData(ASPxPivotGrid pivot, DevExpress.Xpo.Session s, string objectname, string filter = "", params object[] parameter)
    {
        try
        {
            DynamicDataTableClassInfo classInfo = dynamicClasses[objectname];

            if (classInfo != null)
            {
                XPServerCollectionSource ds = new XPServerCollectionSource(s, dynamicClasses[objectname], CriteriaOperator.Parse(filter, parameter));
                pivot.DataSource = ds;
            }
            else
                throw new Exception(string.Format("Đối tượng {0} không tìm thấy trong database. Nếu không có dữ liệu hiển thị thì XPOProfiles để xem điều kiện lọc đúng chưa", objectname));
        }
        catch (Exception ex)
        {
            SiAuto.Main.LogColored(Color.Red, "Loi BindData:" + ex.ToString());
            throw ex;
        }
    }
 public static string TryConnect(ASPxPivotGrid pivotGrid, string cubeName)
 {
     return TryConnect(pivotGrid, "OLAPCNNS", cubeName);
 }