private void pivotGrid_CellDblClick(object sender, PivotCellEventArgs e) { if (!showDrillDown.IsChecked.Value) { return; } GridControl grid = new GridControl(); ThemeManager.SetThemeName(grid, ThemeManager.ApplicationThemeName); grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); grid.View = new TableView() { AllowPerPixelScrolling = true }; grid.ItemsSource = ds; grid.PopulateColumns(); grid.ShowBorder = false; popupContainer = FloatingContainer.ShowDialog(grid, this, new Size(520, 300), new FloatingContainerParameters() { AllowSizing = true, CloseOnEscape = true, Title = "Drill Down Form", ClosedDelegate = null }); AddLogicalChild(popupContainer); }
void IPivotCustomSummaryEvent.Calculate(PivotGridCustomSummaryEventArgs e) { if (e.RowField == null) { decimal currentSum = 0, topSum = 0; PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); for (int i = 0; i < ds.RowCount; i++) { decimal val = Convert.ToDecimal(ds[i][Model.TopObject.FieldDataName]); if (ReferenceEquals(ds[i][Model.TopObject.FieldRowName], _topObject)) { topSum += val; } else { currentSum += val; } } e.CustomValue = currentSum - topSum; } else { e.CustomValue = e.SummaryValue.Summary; } }
// some custom logic to demonstrate the approach in action private void OnPivotCustomCellValue(object sender, PivotCellValueEventArgs e) { if (e.DataField == fieldExtendedPriceUnbound) { PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); decimal value = 0; Dictionary <PivotGridField, object> columnFieldValues = new Dictionary <PivotGridField, object>(); PivotGridField[] columnFields = e.GetColumnFields(); foreach (PivotGridField field in columnFields) { columnFieldValues[field] = e.GetFieldValue(field); } for (int i = 0; i < ds.RowCount; i++) { bool skip = false; foreach (PivotGridField field in columnFields) { if (!Comparer.Equals(ds[i][field], columnFieldValues[field])) { skip = true; break; } } if (skip) { continue; } decimal v1 = Convert.ToDecimal(ds[i][e.DataField]); value += v1; } e.Value = value; } }
protected void ASPxPivotGrid1_CustomSummary(object sender, PivotGridCustomSummaryEventArgs e) { if (e.DataField != fieldExtendedPrice) { return; } // A variable which counts the number of orders whose sum exceeds $500. int order500Count = 0; // Get the record set for 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[fieldExtendedPrice]; if (orderSum >= minSum) { order500Count++; } } // Calculate the percentage. if (ds.RowCount > 0) { e.CustomValue = (decimal)order500Count / ds.RowCount; } }
void ShowDrillDown(PivotDrillDownDataSource drillDownDataSource) { if (drillDownDataSource.RowCount == 0) { DXMessageBox.Show("DrillDown operation returned no rows"); return; } GridControl grid = new GridControl(); grid.View = new TableView() { AllowPerPixelScrolling = true }; grid.ItemsSource = drillDownDataSource; grid.PopulateColumns(); FloatingContainer popupContainer = FloatingWindowContainer.ShowDialog(grid, this, new Size(520, 300), new FloatingContainerParameters() { AllowSizing = true, CloseOnEscape = true, Title = String.Format("Drill Down Results: {0} Rows", drillDownDataSource.RowCount), ClosedDelegate = null, }); AddLogicalChild(popupContainer); }
private void ChangeCellValue(PivotDrillDownDataSource source, decimal oldValue, decimal newValue) { decimal diff = newValue - oldValue; decimal fact = diff == newValue ? diff / source.RowCount : diff / oldValue; for (int i = 0; i < source.RowCount; i++) { decimal value = (decimal)source.GetValue(i, "UnitPrice"); newValue = (value == 0 ? 1 : value) * (1m + fact); DataTable dt = (DataTable)Session["PivotData"]; double price = Convert.ToDouble(newValue); int productID = Convert.ToInt32(source.GetValue(i, "ProductID")); foreach (DataRow dr in dt.Rows) { if (Convert.ToInt32(dr["ProductID"]) == productID) { dr["UnitPrice"] = price; } } Session["PivotData"] = dt; source.SetValue( i, "UnitPrice", newValue ); } }
protected void Button1_Click(object sender, EventArgs e) { PivotDrillDownDataSource ds = ASPxPivotGrid1.CreateDrillDownDataSource(0, 0); PropertyDescriptorCollection props = ((ITypedList)ds).GetItemProperties(null); DataTable table = new DataTable("drilldown"); for (int i = 0; i < props.Count; i++) { table.Columns.Add(props[i].Name, props[i].PropertyType); } object[] row = new object[props.Count]; for (int i = 0; i < ds.RowCount; i++) { for (int j = 0; j < props.Count; j++) { row[j] = ds.GetValue(i, j); } table.Rows.Add(row); } using (StringWriter writer = new StringWriter()) { table.WriteXml(writer, XmlWriteMode.WriteSchema); Session["drilldown"] = writer.ToString(); } }
public void ProcessAction(DevExpress.XtraPivotGrid.PivotCellEventArgs e) { PivotGridListEditor listEditor = ((DevExpress.ExpressApp.ListView)View).Editor as PivotGridListEditor; int columnIndex = e.ColumnIndex; int rowIndex = e.RowIndex; PivotDrillDownDataSource drillDown = listEditor.PivotGridControl.CreateDrillDownDataSource(columnIndex, rowIndex); List <object> keysToShow = new List <object>(); for (int i = 0; i < drillDown.RowCount; i++) { object obj = drillDown[i][0]; if (obj != null) { keysToShow.Add(ObjectSpace.GetKeyValue(obj)); } } if (keysToShow.Count > 0) { string viewId = Application.GetListViewId(View.ObjectTypeInfo.Type); CollectionSourceBase collectionSource = Application.CreateCollectionSource(Application.CreateObjectSpace(), View.ObjectTypeInfo.Type, viewId); collectionSource.Criteria["SelectedObjects"] = new InOperator(ObjectSpace.GetKeyPropertyName(View.ObjectTypeInfo.Type), keysToShow); DevExpress.ExpressApp.ListView listView = Application.CreateListView(viewId, collectionSource, true); ShowViewParameters svp = new ShowViewParameters(listView); svp.TargetWindow = TargetWindow.NewModalWindow; //svp.Context = TemplateContext.View; Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(Frame, null)); } }
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; } }
//获取点击单元格的明细数据 protected string getDetail() { int rowIndex = int.Parse(Request["rowIndex"]); int colIndex = int.Parse(Request["colIndex"]); int pageSize = int.Parse(Request["pageSize"]); int pageIndex = int.Parse(Request["pageIndex"]); string sortField = Request["sortField"]; string sortOrder = Request["SortOrder"]; DataTable dt = ASPxPivotGrid1.DataSource as DataTable; PivotDrillDownDataSource source = ASPxPivotGrid1.CreateDrillDownDataSource(colIndex, rowIndex); List <int> list = new List <int>(); for (int i = 0; i < source.RowCount; i++) { list.Add(source[i].ListSourceRowIndex); } var result = dt.Copy(); for (int i = result.Rows.Count - 1; i >= 0; i--) { if (list.Contains(i) == false) { result.Rows.RemoveAt(i); } } if (!string.IsNullOrEmpty(sortField)) { if (sortOrder == "asc") { result = result.AsEnumerable().OrderBy(c => c[sortField]).CopyToDataTable(); } else { result = result.AsEnumerable().OrderByDescending(c => c[sortField]).CopyToDataTable(); } } int total = result.Rows.Count; for (int i = result.Rows.Count - 1; i >= 0; i--) { if (i < pageIndex * pageSize || i >= (pageIndex + 1) * pageSize) { result.Rows.RemoveAt(i); } } IsoDateTimeConverter datetype = new IsoDateTimeConverter(); datetype.DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"; var objResult = new { total = total, data = result }; return(JsonConvert.SerializeObject(objResult, datetype)); }
public DrillDownForm(PivotDrillDownDataSource dataSource) { this.dataSource = dataSource; InitializeComponent(); //Icon = ResourceImageHelper.CreateIconFromResourcesEx("DevExpress.XtraPivotGrid.Demos.AppIcon.ico", typeof(DrillDownForm).Assembly); gridControl1.DataSource = dataSource; ((GridView)gridControl1.MainView).OptionsView.ShowGroupPanel = false; }
private ToolTipControlInfo toolTipFor(PivotDrillDownDataSource ds, string nameField, string descriptionField, ApplicationIcon icon) { var name = ds.StringValue(nameField); var description = ds.StringValue(descriptionField); var superToolTip = _toolTipCreator.CreateToolTip(description, name, icon); return(_toolTipCreator.ToolTipControlInfoFor(name, superToolTip)); }
private void pivotGridControl_EditValueChanged(object sender, EditValueChangedEventArgs e) { PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); for (int j = 0; j < ds.RowCount; j++) { ds[j][e.DataField] = e.Editor.EditValue; } }
public static T Value <T>(this PivotDrillDownDataSource ds, string fieldName) where T : class { if (ds.RowCount == 0) { return(default(T)); } return(Value <T>(ds[0], fieldName)); }
void _pivotGridControl_EditValueChanged(object sender, EditValueChangedEventArgs e) { PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); for (int j = 0; j < ds.RowCount; j++) { ds[j][e.DataField] = XpandReflectionHelper.ChangeType(e.Editor.EditValue, ds[j][e.DataField].GetType()); } }
public void InstantiateIn(Control container) { PivotGridCellTemplateContainer c = container as PivotGridCellTemplateContainer; PivotDrillDownDataSource ds = c.Item.CreateDrillDownDataSource(); if (ds.RowCount > 0) { int id = Convert.ToInt32(ds[0]["ProductID"]); c.Controls.Add(new MyLink(c.Text, id)); } }
protected void ASPxPivotGrid1_CustomSummary(object sender, DevExpress.Web.ASPxPivotGrid.PivotGridCustomSummaryEventArgs e) { decimal discount = Convert.ToDecimal(e.SummaryValue.Summary); decimal unitPrice = 0; PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); for (int i = 0; i < ds.RowCount; i++) { unitPrice += Convert.ToDecimal(ds[i]["UnitPrice"]); } e.CustomValue = new SBSInf(discount, unitPrice); }
public void InstantiateIn(Control container) { PivotGridFieldValueTemplateContainer c = (PivotGridFieldValueTemplateContainer)container; PivotGridFieldValueHtmlCell cell = c.CreateFieldValue(); PivotFieldValueItem valueItem = c.ValueItem; PivotDrillDownDataSource ds = valueItem.CreateDrillDownDataSource(); int id = Convert.ToInt32(ds[0]["ProductID"]); cell.Controls.AddAt(cell.Controls.IndexOf(cell.TextControl), new MyLink(c.Text, id)); cell.Controls.Remove(cell.TextControl); c.Controls.Add(cell); }
private bool DataProvidesSameValues(PivotDrillDownDataSource ds, DevExpress.Web.ASPxPivotGrid.PivotGridField fieldCurrency) { object firstValue = ds[0][fieldCurrency]; for (int i = 1; i < ds.RowCount; i++) { if (!object.Equals(firstValue, ds[i][fieldCurrency])) { return(false); } } return(true); }
void pivotGridControl1_OnCellEdit(DependencyObject sender, PivotCellEditEventArgs args) { PivotGridControl pivotGrid = (PivotGridControl)sender; PivotGridField fieldExtendedPrice = pivotGrid.Fields["ExtendedPrice"]; PivotDrillDownDataSource ds = args.CreateDrillDownDataSource(); decimal difference = args.NewValue - args.OldValue; decimal factor = (difference == args.NewValue) ? (difference / ds.RowCount) : (difference / args.OldValue); for (int i = 0; i < ds.RowCount; i++) { decimal value = Convert.ToDecimal(ds[i][fieldExtendedPrice]); decimal newValue = (value == 0m) ? factor : value * (1m + factor); ds.SetValue(i, fieldExtendedPrice, newValue); } }
private void pivotGridControl1_CustomDrawCell(object sender, DevExpress.XtraPivotGrid.PivotCustomDrawCellEventArgs e) { if (e.DataField == fieldData) { PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); int hiddenValue = (int)ds.GetValue(0, "hidden"); if (hiddenValue > 0) { e.Appearance.BackColor = Color.Green; } if (hiddenValue < 0) { e.Appearance.BackColor = Color.Red; } } }
double GetAverageTransaction() { PivotDrillDownDataSource ds = pivotGrid.CreateDrillDownDataSource(); if (ds.RowCount == 0) { return(0); } double transactionSum = 0; for (int i = 0; i < ds.RowCount; i++) { transactionSum += Convert.ToDouble(ds[i]["ProductSales"]); } return(transactionSum / ds.RowCount); }
//'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"; } }
private void CalculateSummary() { try { PivotDrillDownDataSource ds = pivotGridUserLoginDetails.CreateDrillDownDataSource(); presentDictionary.Clear(); absentDictionary.Clear(); for (int i = 0; i < ds.RowCount; i++) { var value = ds[i]["Attendance"]; var date = ds[i]["Date"]; if (value.ToString() == "P") { if (presentDictionary.ContainsKey(date.ToString())) { int oldCount = presentDictionary[date.ToString()]; oldCount++; presentDictionary[date.ToString()] = oldCount; } else { presentDictionary.Add(date.ToString(), 1); } } if (value.ToString() == "A") { if (absentDictionary.ContainsKey(date.ToString())) { int oldCount = absentDictionary[date.ToString()]; oldCount++; absentDictionary[date.ToString()] = oldCount; } else { absentDictionary.Add(date.ToString(), 1); } } } } catch (Exception e) { XtraMessageBox.Show("Something went wrong contact system admin"); } }
public void ProcessAction(string parameter) { string[] indices = parameter.Split(';'); int columnIndex = Int32.Parse(indices[0]); int rowIndex = Int32.Parse(indices[1]); string columnValueType = indices[2]; string rowValueType = indices[3]; var editor = (ASPxPivotGridListEditor)View.Editor; PivotDrillDownDataSource drillDown = editor.PivotGridControl.CreateDrillDownDataSource(columnIndex, rowIndex); ArrayList keysToShow = new ArrayList(); foreach (PivotDrillDownDataRow row in drillDown) { object key = row[View.ObjectTypeInfo.KeyMember.Name]; if (key != null) { keysToShow.Add(key); } } // Show list view string viewId = Application.GetListViewId(View.ObjectTypeInfo.Type); CollectionSourceBase collectionSource = Application.CreateCollectionSource(Application.CreateObjectSpace(), View.ObjectTypeInfo.Type, viewId); collectionSource.Criteria["SelectedObjects"] = new InOperator(ObjectSpace.GetKeyPropertyName(View.ObjectTypeInfo.Type), keysToShow); ListView listView = Application.CreateListView(viewId, collectionSource, true); ShowViewParameters svp = new ShowViewParameters(listView); svp.TargetWindow = TargetWindow.NewModalWindow; // Add Default Values controller if (TargetDefaultValuesController != null) { var pivotFieldValuePairs = GetPivotFieldValues(editor.PivotGridControl, columnIndex, rowIndex); Dictionary <string, object> dicPivotFieldValues = GetDefaultValues(pivotFieldValuePairs); var defaultValuesController = (Xafology.ExpressApp.Controllers.DefaultValuesViewController)Activator.CreateInstance(TargetDefaultValuesController, dicPivotFieldValues); svp.Controllers.Add(defaultValuesController); } Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(Frame, null)); }
private void pivotGridControl1_EditValueChanged(object sender, DevExpress.XtraPivotGrid.EditValueChangedEventArgs e) { try { double newValue = Convert.ToDouble(e.Editor.EditValue); double oldValue = Convert.ToDouble(e.Value); PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); for (int i = 0; i < ds.RowCount; i++) { double rowValue = Convert.ToDouble(ds[i][e.DataField]); ds.SetValue(i, e.DataField, newValue); } } catch (Exception ex) { MessageBox.Show("El valor asignado es incorrecto"); } }
public static Dictionary <object, decimal> GetSummaryValues(PivotDrillDownDataSource ds, PivotGridField valueField, PivotGridField dataField) { Dictionary <object, decimal> dict = new Dictionary <object, decimal>(); for (int i = 0; i < ds.RowCount; i++) { object currentObject = ds[i][valueField]; decimal currentValue = Convert.ToDecimal(ds[i][dataField]); if (dict.ContainsKey(currentObject)) { dict[currentObject] += currentValue; } else { dict.Add(currentObject, currentValue); } } return(dict); }
void IXafCallbackHandler.ProcessAction(string parameter) { string[] indices = parameter.Split(';'); int columnIndex = Int32.Parse(indices[0]); int rowIndex = Int32.Parse(indices[1]); PivotDrillDownDataSource drillDown = ((ASPxPivotGridListEditor)View.Editor).PivotGridControl.CreateDrillDownDataSource(columnIndex, rowIndex); string name = View.ObjectTypeInfo.KeyMember.Name; IList keysToShow = drillDown.Cast <PivotDrillDownDataRow>().Where(row => row[name] != null).Select(row => row[name]).ToList(); if (keysToShow.Count > 0) { Type targetType = View.ObjectTypeInfo.Type; string viewId = Application.GetListViewId(targetType); CollectionSourceBase collectionSource = Application.CreateCollectionSource(Application.CreateObjectSpace(targetType), targetType, viewId); collectionSource.Criteria["SelectedObjects"] = new InOperator(ObjectSpace.GetKeyPropertyName(targetType), keysToShow); ListView listView = Application.CreateListView(viewId, collectionSource, false); Application.ShowViewStrategy.ShowViewInPopupWindow(listView); } }
private void pivotGridControl1_CustomAppearance(object sender, PivotCustomAppearanceEventArgs e) { PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); foreach (PivotDrillDownDataRow row in ds) { if (Convert.ToInt32(row["Day_Of_Week"].ToString()) == 1) { e.Appearance.BackColor = Color.OrangeRed; e.Appearance.ForeColor = Color.White; e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold); } if (Convert.ToInt32(row["Day_Of_Week"].ToString()) == 1 && (row["Attendance"].ToString() == "P")) { e.Appearance.BackColor = Color.Green; e.Appearance.ForeColor = Color.White; e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold); } if (Convert.ToInt32(row["Day_Of_Week"].ToString()) == 7) { e.Appearance.BackColor = Color.Yellow; e.Appearance.ForeColor = Color.DarkSlateBlue; e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold); } if (Convert.ToInt32(row["Day_Of_Week"].ToString()) == 7 && (row["Attendance"].ToString() == "P")) { e.Appearance.BackColor = Color.Green; e.Appearance.ForeColor = Color.White; e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold); } if (Convert.ToInt32(row["Day_Of_Week"].ToString()) != 7 && (row["Attendance"].ToString() != "P") && Convert.ToInt32(row["Day_Of_Week"].ToString()) != 1) { e.Appearance.ForeColor = Color.Red; e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold); } if (Convert.ToInt32(row["Day_Of_Week"].ToString()) != 7 && (row["Attendance"].ToString() == "P") && Convert.ToInt32(row["Day_Of_Week"].ToString()) != 1) { e.Appearance.ForeColor = Color.Green; e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold); } } }
private void pivotGridControl1_CellDoubleClick(object sender, PivotCellEventArgs e) { GridControl grid = new GridControl(); ThemeManager.SetThemeName(grid, ThemeManager.ApplicationThemeName); grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); grid.ItemsSource = ds; grid.PopulateColumns(); FloatingWindowContainer.ShowDialogContent(grid, this, new Size(520, 300), new FloatingContainerParameters() { AllowSizing = true, CloseOnEscape = true, Title = "Drill Down Form", ClosedDelegate = null }); }
public void fillDataSource(PivotDrillDownDataSource ipSource) { gridControl1.DataSource = ipSource; gridControl1.RefreshDataSource(); }
public void display(PivotDrillDownDataSource ip_ds) { m_grc.DataSource = ip_ds; this.ShowDialog(); }