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();
        }
    }
Beispiel #2
0
        public AvrPivotGridHelperWeb(ASPxPivotGrid pivotGrid)
        {
            DisplayTextHandler = new DisplayTextHandler();
            m_BaseFields       = pivotGrid.Fields;

            m_DataAreaFields = new List <IAvrPivotGridField>();
            foreach (PivotGridField field in pivotGrid.GetFieldsByArea(PivotArea.DataArea))
            {
                //todo: change this initialization
                if (field is IAvrPivotGridField)
                {
                    m_DataAreaFields.Add((IAvrPivotGridField)field);
                }
            }

            m_ColumnAreaFields = new List <IAvrPivotGridField>();
            foreach (PivotGridField field in pivotGrid.GetFieldsByArea(PivotArea.ColumnArea))
            {
                //todo: change this initialization
                if (field is IAvrPivotGridField)
                {
                    m_ColumnAreaFields.Add((IAvrPivotGridField)field);
                }
            }

            m_RowAreaFields = new List <IAvrPivotGridField>();
            foreach (PivotGridField field in pivotGrid.GetFieldsByArea(PivotArea.RowArea))
            {
                //todo: change this initialization
                if (field is IAvrPivotGridField)
                {
                    m_RowAreaFields.Add((IAvrPivotGridField)field);
                }
            }
            var fields = RowAreaFields;

            fields.AddRange(ColumnAreaFields);
            GenderField   = AvrPivotGridHelper.GetGenderField(fields);
            AgeGroupField = AvrPivotGridHelper.GetAgeGroupField(fields);

            PivotWebData = pivotGrid.Data;

            WebPivotGrid = pivotGrid;
        }
Beispiel #3
0
    private object GetTotalValue(PivotGridCellTemplateItem c, ASPxPivotGrid sourcePivotGrid)
    {
        List <PivotGridField> columnFields      = pivotGrid.GetFieldsByArea(DevExpress.XtraPivotGrid.PivotArea.ColumnArea);
        List <PivotGridField> rowFields         = pivotGrid.GetFieldsByArea(DevExpress.XtraPivotGrid.PivotArea.RowArea);
        List <object>         rowFieldValues    = new List <object>();
        List <object>         columnFieldValues = new List <object>();

        if (c.ColumnField != null)
        {
            foreach (PivotGridField field in columnFields)
            {
                if (field.AreaIndex > c.ColumnField.AreaIndex)
                {
                    continue;
                }
                object currentValue = c.GetFieldValue(field);
                if (currentValue != null)
                {
                    columnFieldValues.Add(currentValue);
                }
            }
        }
        if (c.RowField != null)
        {
            foreach (PivotGridField field in rowFields)
            {
                if (field.AreaIndex > c.RowField.AreaIndex)
                {
                    continue;
                }
                object currentValue = c.GetFieldValue(field);
                if (currentValue != null)
                {
                    rowFieldValues.Add(currentValue);
                }
            }
        }
        sourcePivotGrid.EnsureRefreshData();
        object res = sourcePivotGrid.Data.GetCellValue(columnFieldValues.ToArray(), rowFieldValues.ToArray(), c.DataField);

        return(res);
    }
Beispiel #4
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();
    }