//'DevExpress.Web.ASPxPivotGrid.PivotGridCustomSummaryEventArgs' and 'DevExpress.XtraPivotGrid.PivotGridCustomSummaryEventArgs
    protected void pivotENT_CustomSummary(object sender, DevExpress.Web.ASPxPivotGrid.PivotGridCustomSummaryEventArgs e)
    {
        var x = e.DataField;

        if (e.DataField.FieldName != "studyactionID" && e.DataField.FieldName != "studymeasID")
        {
            return;
        }

        // Get the record set corresponding to the current cell.
        PivotDrillDownDataSource ds = e.CreateDrillDownDataSource();

        // Calculate the percentage.
        if (ds.RowCount > 0)
        {
            e.CustomValue = "X";
        }
    }
Exemple #2
0
    protected void ASPxPivotGrid1_CustomSummary(object sender, DevExpress.Web.ASPxPivotGrid.PivotGridCustomSummaryEventArgs e)
    {
        ASPxPivotGrid pivot = (ASPxPivotGrid)sender;

        // In the root IF clause, determine the summary type.
        // All fields at the level lower than the "Company" should show Min values.
        // All fields are located in the Row Area, so it is necessary to check the AreaIndex property of the e.RowField.
        if (e.RowField != null && e.RowField.AreaIndex >= fieldCompanyName.AreaIndex)
        {
            // The Pivot Grid automatically calculates predefined summary values for all cells.
            // To obtain summary values, use the e.SummaryValue to get the SummaryValue object,
            // get the Min value and assign it to the CustomValue property.
            e.CustomValue = e.SummaryValue.Min;
        }
        else
        {
            // The Pivot Grid calculates summary values for all cells based on the underlying data source rows regardless of the cell type.
            // However, the current scenario calculates total values based on the low level cell summary values.
            // For the Year field rows it is necessary to group data by Company,
            // find Min value in each group and finally summarize all Min values.
            // For the Grand Total cell it is necessary to group data by the Year, Quarter and Company values.
            //
            // To get grouping fields, iterate through the Fields collection
            // and find the fields located in the Row Area below the current e.RowField but above the Company field.
            var groupingFields = pivot.Fields.Cast <PivotGridField>().Where(f => f.Visible && f.Area == fieldCompanyName.Area && f.AreaIndex <= fieldCompanyName.AreaIndex && (e.RowField == null || f.AreaIndex > e.RowField.AreaIndex));
            // Get the underlying data.
            var drillDownDataSource = e.CreateDrillDownDataSource().Cast <PivotDrillDownDataRow>();
            List <IEnumerable <PivotDrillDownDataRow> > temporaryList = new List <IEnumerable <PivotDrillDownDataRow> >();
            temporaryList.Add(drillDownDataSource);
            IEnumerable <IEnumerable <PivotDrillDownDataRow> > dataGroups = temporaryList;
            // Group the entire data source by the recently obtained groupingFields:
            foreach (var field in groupingFields)
            {
                var localField = field;
                dataGroups = dataGroups.SelectMany(groupRows => groupRows.GroupBy(r => r[localField]).Select(g => g.AsEnumerable()));
            }
            // The final step is to iterate through all groups, find a Min value in each group and calculate the sum of all Min values.
            var value = dataGroups.Sum(groupRows => groupRows.Min(r => Convert.ToDecimal(r[e.FieldName])));
            e.CustomValue = value;
        }
    }
Exemple #3
0
    //protected void cboSubjSet_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //	Debug.Print("cboSubjSet_SelectedIndexChanged" + System.DateTime.Now.ToString());

    //	//ViewState["subjNeedBind"] = "true";
    //	//int set = Convert.ToInt32(cboSubjSet.Value.ToString());
    //	//GetSelectedSubjects(set);
    //}
    #endregion



    #region PivotTable of Selected Measures


    protected void PivotSelMeas_Concat(object sender, DevExpress.Web.ASPxPivotGrid.PivotGridCustomSummaryEventArgs e)
    {
//		Debug.Print("ENTER PivotSelMeas_Concat");
        var x = e.DataField;

        //if (e.DataField != field_meas) return;
        if (e.DataField.Name != "field_meas")
        {
            return;
        }

        // Get the record set corresponding to the current cell.
        PivotDrillDownDataSource ds = e.CreateDrillDownDataSource();

        string concat = "";

        // Iterate through the records and count the orders.
        for (int i = 0; i < ds.RowCount; i++)
        {
            PivotDrillDownDataRow row = ds[i];
            string sep = (i == 0) ? "" : "<br>";

            string newtext = row["StudyMeasName"].ToString();
            string isREL   = row["isREL"].ToString();

            if (isREL == "REL")
            {
                newtext = String.Format(@"<p style=""background-color: gold; display:inline; text-align: right;"">{0}</p>", newtext);
            }

            concat = String.Format("{0}{1}{2}", concat, sep, newtext);
        }

        if (ds.RowCount > 0)
        {
            e.CustomValue = concat;
        }
    }