private void pivotGridControl1_CustomSummary(object sender, PivotCustomSummaryEventArgs e) { if (e.DataField != fieldFreight) { return; } // A variable which counts the number of orders whose freight cost exceeds $50. int order50Count = 0; // Get the record set corresponding to the current cell. PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); // Iterate through the records and count the orders. for (int i = 0; i < ds.RowCount; i++) { PivotDrillDownDataRow row = ds[i]; // Get the order's total sum. decimal orderSum = (decimal)row[fieldFreight]; if (orderSum >= minSum) { order50Count++; } } // Calculate the percentage. if (ds.RowCount > 0) { e.CustomValue = (decimal)order50Count / ds.RowCount; } }
private void pivotDgProjectPlanning_CustomSummary(object sender, PivotCustomSummaryEventArgs e) { string name = e.DataField.Name; if (name == "fieldQtyActualBudDiff") { e.CustomValue = CalculateQty("Qty", "BudgetQty", e.CreateDrillDownDataSource()); } else if (name == "fieldQtyNormBudDiff") { e.CustomValue = CalculateQty("NormQty", "BudgetQty", e.CreateDrillDownDataSource()); } else if (name == "fieldQtyActualNormDiff") { e.CustomValue = CalculateQty("Qty", "NormQty", e.CreateDrillDownDataSource()); } else if (name == "fieldSalesActualBudgetDiff") { e.CustomValue = CalculateQty("Sales", "BudgetSales", e.CreateDrillDownDataSource()); } else if (name == "fieldCostActualBudgetDiff") { e.CustomValue = CalculateQty("Cost", "BudgetCost", e.CreateDrillDownDataSource()); } }
void CustomSummary(object sender, PivotCustomSummaryEventArgs e) { switch (e.DataField.FieldName) { case "Percentage": decimal quoteSummary = 0; decimal opportunitySummary = 0; foreach (PivotDrillDownDataRow row in e.CreateDrillDownDataSource()) { quoteSummary += (decimal)row["Total"]; opportunitySummary += (decimal)row["MoneyOpportunity"]; } if (quoteSummary != 0) { e.CustomValue = 100M * opportunitySummary / quoteSummary; } break; } }
private void PivotGrid_CustomSummary(object sender, PivotCustomSummaryEventArgs e) { if (e.DataField.Name == Name) { if ((e.ColumnField == null) || (e.RowField == null)) { //this is Grand Total cell e.CustomValue = "Grand Total"; return; } int lastRowFieldIndex = PivotGrid.GetFieldsByArea(FieldArea.RowArea).Count() - 1; int lastColumnFieldIndex = PivotGrid.GetFieldsByArea(FieldArea.ColumnArea).Count() - 1; if (e.RowField.AreaIndex == lastRowFieldIndex && e.ColumnField.AreaIndex == lastColumnFieldIndex) { //this is Ordinary cell e.CustomValue = e.SummaryValue.Summary; } else { //this is Total cell e.CustomValue = "Total"; } } }
//private void ContextMenuItemSourceClick(object sender, RoutedEventArgs e) //{ // var sourceWh = sender as MenuItem; // CellArgs.SetValues[0].Value = sourceWh.Header; // CellClickInputData(this, CellArgs); //} //private void ContextMenuItemSourceMethodClick(object sender, RoutedEventArgs e) //{ // var sourceMethod = sender as MenuItem; // CellArgs.SetValues[0].Value = sourceMethod.Tag; // CellClickInputData(this, CellArgs); //} //private void ContextMenuItemOrderPlaceClick(object sender, RoutedEventArgs e) //{ // var orderPlace = sender as MenuItem; // CellArgs.SetValues[0].Value = orderPlace.Tag; // CellClickInputData(this, CellArgs); //} private static void PivotGridControlRowOrientedCustomSummary(object sender, PivotCustomSummaryEventArgs e) { if (e.FieldName.Contains("NEW")) { bool isNull = false; var list = e.CreateDrillDownDataSource(); for (int index = 0; index < list.RowCount; index++) { PivotDrillDownDataRow row = list[index]; if (isNull == false) { if (e.FieldName.Equals("DIM_ITEMLOC_SOURCEWH_NEW")) { if (row["DIM_ITEMLOC_SOURCEMETHOD_NEW"] == null) { isNull = true; } else if ((Convert.ToChar(row["DIM_ITEMLOC_SOURCEMETHOD_NEW"]) == (char)SourceMethods.W || Convert.ToChar(row["DIM_ITEMLOC_SOURCEMETHOD_NEW"]) == (char)SourceMethods.T) && row["DIM_ITEMLOC_SOURCEWH_NEW"] == null) { isNull = true; } } else if (row[e.FieldName] == null) { isNull = true; } } } object val = e.SummaryValue.Min != e.SummaryValue.Max ? "?" : e.SummaryValue.Max; CellRowOriented cellValue = new CellRowOriented { Value = (val == null ? "" : Convert.ToString(val)), IsNull = isNull }; //e.CustomValue = e.SummaryValue.Min != e.SummaryValue.Max ? "xxx" : e.SummaryValue.Max; e.CustomValue = cellValue; } else { e.CustomValue = e.SummaryValue.Min != e.SummaryValue.Max ? "?" : e.SummaryValue.Max; } }
void OnPivotGridCustomSummary(object sender, PivotCustomSummaryEventArgs e) { e.CustomValue = e.SummaryValue.Summary; }
bool IsGrandTotal(PivotCustomSummaryEventArgs e) { return(e.RowField == null || e.ColumnField == null); }
private static void PivotGridControlModifiedCustomSummary(object sender, PivotCustomSummaryEventArgs e) { var list = e.CreateDrillDownDataSource(); bool[] action = { false, false, false }; for (int index = 0; index < list.RowCount; index++) { PivotDrillDownDataRow row = list[index]; // 0 : no action // 1 : add action // -1 : remove action // 2 : modify action int value = Convert.ToInt32(row["ACTION"]); int status = Convert.ToInt32(row["MEASURE_STATUS"]); if (value == 1 || value == 4 && status == 0) action[0] = true; if (value == -1) action[1] = true; if (value == 2 || value == 4 && status == 1) action[2] = true; } string resultModify = (action[2] ? "1" : "0"); string resultAction = (action[0] ? "1" : "0") + (action[1] ? "1" : "0"); string resultSummary = "0"; if (e.SummaryValue.Max != e.SummaryValue.Min) { resultSummary = "1"; } else if (Convert.ToInt32(e.SummaryValue.Max) == 1) { resultSummary = "2"; } else if (Convert.ToInt32(e.SummaryValue.Min) == 0) { resultSummary = "0"; } e.CustomValue = resultAction + "&" + resultModify + "&" + Convert.ToInt32(e.SummaryValue.Summary) + "&" + resultSummary; }