public static FilterInfo[] GetFilterInfo(PivotGridGroup group, PivotFilterType targetType) { if (group.FilterValues.HasFilter) { if (group.FilterValues.FilterType == targetType) { return(group.FilterValues.Values.Select(v => new FilterInfo(v)).ToArray()); } else { return(GetConvertedFilerInfo(group, group.FilterValues.Values, null)); } } else { return(new FilterInfo[0]); } }
void radioGroup1_SelectedIndexChanged(object sender, EventArgs e) { if (pivotGridControl1 == null) { return; } this.pivotGridControl1.BeginUpdate(); PivotGridGroup group = this.pivotGridControl1.Groups[0]; group.FilterValues.Reset(); group.FilterValues.BeginUpdate(); switch (radioGroup1.SelectedIndex) { case 0: group.FilterValues.FilterType = PivotFilterType.Excluded; break; case 1: group.FilterValues.FilterType = PivotFilterType.Included; group.FilterValues.Values.Add(2009).ChildValues.Add(12); group.FilterValues.Values.Add(2010).ChildValues.Add(1); break; case 2: group.FilterValues.FilterType = PivotFilterType.Excluded; group.FilterValues.Values.Add(2009); break; case 3: group.FilterValues.FilterType = PivotFilterType.Included; SelectFirstDays(group); break; } group.FilterValues.EndUpdate(); this.pivotGridControl1.EndUpdate(); if (radioGroup1.SelectedIndex == 3) { fieldMonth.ExpandAll(); } else { fieldMonth.CollapseAll(); } }
private void listBox1_SelectedIndexChanged(object sender, System.Windows.RoutedEventArgs e) { if (pivotGridControl1 == null) { return; } this.pivotGridControl1.BeginUpdate(); PivotGridGroup group = this.pivotGridControl1.Groups[0]; group.FilterValues.Reset(); group.FilterValues.BeginUpdate(); switch (listBox1.SelectedIndex) { case 0: group.FilterValues.FilterType = FieldFilterType.Excluded; break; case 1: group.FilterValues.FilterType = FieldFilterType.Included; group.FilterValues.Values.Add(1994).ChildValues.Add(12); group.FilterValues.Values.Add(1995).ChildValues.Add(1); break; case 2: group.FilterValues.FilterType = FieldFilterType.Excluded; group.FilterValues.Values.Add(1994); break; case 3: group.FilterValues.FilterType = FieldFilterType.Included; SelectFirstDays(group); break; } group.FilterValues.EndUpdate(); this.pivotGridControl1.EndUpdate(); if (listBox1.SelectedIndex == 3) { fieldMonth.ExpandAll(); } else { fieldMonth.CollapseAll(); } }
/// <summary> /// Add a new field associated with specified ResultsField /// </summary> /// <param name="rfld"></param> /// <param name="Fields"></param> /// <param name="area"></param> /// <param name="visible"></param> /// <param name="pgi"></param> /// <returns></returns> internal static PivotGridFieldMx AddField( ResultsField rfld, List <PivotGridFieldMx> Fields, PivotArea area, bool visible, PivotGridGroup group, GroupingTypeEnum pgi) { QueryColumn qc = rfld.QueryColumn; MetaColumn mc = qc.MetaColumn; QueryTable qt = qc.QueryTable; PivotGridFieldMx f = new PivotGridFieldMx(); if (mc.IsKey) { f.ImageIndex = (int)Bitmaps16x16Enum.Key; } else { f.ImageIndex = (int)mc.DataTypeImageIndex; } f.UnboundFieldName = qt.Alias + "." + mc.Name + // identify by tableAlias.mcName (allows multiple instances of same metatable in query) "." + (UnboundFieldNameCount++); // and make unique in case used in multiple PivotGroupIntervals (needed?) f.ResultsField = rfld; // store associated results field f.SummaryTypeMx = SummaryTypeEnum.Count; f.Area = area; f.Visible = visible; // if not visible then put in list of unused fields f.Aggregation.GroupingType = pgi; PivotGridControlMx.SetFieldCaption(f); Fields.Add(f); if (group != null) { group.Add(f); // add to group } return(f); }
private static FilterInfo[] GetConvertedFilerInfo(PivotGridGroup group, PivotGroupFilterValuesCollection filterValues, object[] parentValues) { if (!group.FilterValues.HasFilter || filterValues == null || filterValues.Count == 0) { return(new FilterInfo[0]); } var currentField = filterValues.Items[0].Field; var uniqueValues = group.GetUniqueValues(parentValues); var invertedFilterInfo = new List <FilterInfo>(); foreach (object v in uniqueValues) { PivotGroupFilterValue filterValue = filterValues.FirstOrDefault(fv => Object.Equals(fv.Value, v)); if (filterValue == null) { invertedFilterInfo.Add(new FilterInfo() { Field = currentField, Value = v }); } else { if (filterValue.ChildValues != null && filterValue.ChildValues.Count > 0) { invertedFilterInfo.Add(new FilterInfo() { Field = currentField, Value = v, ChildValues = GetConvertedFilerInfo(group, filterValue.ChildValues, (parentValues ?? new object[0]).Union(new object[] { v }).ToArray()) }); } } } return(invertedFilterInfo.ToArray()); }
protected void ASPxRadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { PivotGridGroup group = ASPxPivotGrid1.Groups[0]; group.FilterValues.Reset(); switch (ASPxRadioButtonList1.SelectedIndex) { case 0: group.FilterValues.FilterType = PivotFilterType.Excluded; fieldShippedYear.ExpandAll(); fieldShippedMonth.ExpandAll(); break; case 1: group.FilterValues.FilterType = PivotFilterType.Included; group.FilterValues.Values.Add(2014).ChildValues.Add(12); group.FilterValues.Values.Add(2015).ChildValues.Add(1); fieldShippedYear.ExpandAll(); fieldShippedMonth.CollapseAll(); break; case 2: group.FilterValues.FilterType = PivotFilterType.Excluded; group.FilterValues.Values.Add(2014); fieldShippedYear.CollapseAll(); fieldShippedMonth.CollapseAll(); break; case 3: group.FilterValues.FilterType = PivotFilterType.Included; SelectFirstDays(group); fieldShippedYear.ExpandAll(); fieldShippedMonth.ExpandAll(); break; } }
/// <summary> /// Render the view into the specified results control /// </summary> public override void ConfigureRenderingControl() { Query q; ResultsFormat rf = ResultsFormat; ResultsTable rt; QueryTable qt; MetaTable mt; ResultsField rfld; Mobius.Data.QueryColumn qc; MetaColumn mc; PivotGridField pgf; bool includeActivityClass = true; if (!BuildUnpivotedResults(includeActivityClass)) { return; } PivotGridPropertiesMx p = PivotGridPropertiesMx; if (p == null) { return; } if (p.PivotFields == null) // if not defined then configure { PivotGridCtl.Fields.Clear(); // clear any prev display PivotGridCtl.Groups.Clear(); if (DataIncludesDates) { DialogResult dr = DateGroupingDialog.ShowDialog(ref DateGroupInterval); } p.PivotFields = new List <PivotGridFieldMx>(); foreach (ResultsTable rt0 in rf.Tables) // determine visible fields { rt = rt0; qt = rt.QueryTable; mt = qt.MetaTable; if (Lex.Eq(mt.Name, MultiDbAssayDataNames.CombinedNonSumTableName)) { if ((rfld = rt.GetResultsFieldByName("activity_bin")) != null) { pgf = PivotGridView.AddField(rfld, p.PivotFields, PivotArea.RowArea, true, null, GroupingTypeEnum.EqualValues); } if ((rfld = rt.GetResultsFieldByName("run_dt")) != null && DataIncludesDates && DateGroupInterval != GroupingTypeEnum.EqualValues) { GroupingTypeEnum pgi = DateGroupInterval; int intervalCnt = 0; bool week = false, month = false, year = false; // include larger date units up to year if (pgi == GroupingTypeEnum.DateDayOfWeek) { week = month = year = true; intervalCnt = 3; } else if (pgi == GroupingTypeEnum.DateWeekOfMonth) { intervalCnt = 3; month = year = true; } else if (pgi == GroupingTypeEnum.DateMonth || pgi == GroupingTypeEnum.DateQuarter) { year = true; } PivotGridGroup g = null; if (intervalCnt > 1) { g = new PivotGridGroup(); PivotGridCtl.Groups.Add(g); } if (year) { PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, g, GroupingTypeEnum.DateYear); } if (month) { PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, g, GroupingTypeEnum.DateMonth); } if (week) { PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, g, GroupingTypeEnum.DateWeekOfMonth); } PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, g, pgi); } if ((rfld = rt.GetResultsFieldByName("assy_nm")) != null) { pgf = PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, null, GroupingTypeEnum.EqualValues); } if ((rfld = rt.GetResultsFieldByName("rslt_val")) != null) { pgf = PivotGridView.AddField(rfld, p.PivotFields, PivotArea.DataArea, true, null, GroupingTypeEnum.EqualValues); } } else // tables other than the standard pivoted table { foreach (ResultsField rfld0 in rt.Fields) { rfld = rfld0; qc = rfld.QueryColumn; mc = qc.MetaColumn; } } } } // done defining initial set of fields SyncMxFieldListWithSourceQuery(BaseQuery, ref p.PivotFields); // be sure main grid & pivot view fields are in synch ConfigurePivotGridControl(); // configure the control to display the data PivotGridCtl.DataSource = Qm.DataTableManager.DataSource; // set the data table to start rendering return; }