/// <summary> /// The event handler method is hooked when the radio button was clicked. /// </summary> /// <param name="sender">The radio button.</param> /// <param name="e">The event argument.</param> private void OlapDataSource_Checked(object sender, RoutedEventArgs e) { RootLayout.Children.RemoveAt(0); pivotGrid = new SfPivotGrid { Margin = new Thickness(5) }; pivotGrid.SetBinding(SfPivotGrid.ShowGroupingBarProperty, showGroupingBarBinding); pivotGrid.SetBinding(SfPivotGrid.EnableGroupingBarFilteringProperty, enableGroupingBarFilteringBinding); pivotGrid.SetBinding(SfPivotGrid.EnableGroupingBarRemovingProperty, enableGroupingBarRemovingBinding); pivotGrid.SetBinding(SfPivotGrid.EnableRowHeaderAreaProperty, enableRowHeaderBinding); pivotGrid.SetBinding(SfPivotGrid.EnableColumnHeaderAreaProperty, enableColumnHeaderBinding); pivotGrid.SetBinding(SfPivotGrid.EnableFilterHeaderAreaProperty, enableFilterHeaderBinding); pivotGrid.SetBinding(SfPivotGrid.EnableValueHeaderAreaProperty, enableValueHeaderBinding); chk_EnableGroupingBarSorting.Visibility = Visibility.Collapsed; pivotGrid.SetBinding(SfPivotGrid.AllowMultiFunctionalSortFilterProperty, allowMultiFunctionalSortFilterBinding); chk_AllowMultiFunctionalSortFilter.Visibility = Visibility.Collapsed; busyIndicator.IsBusy = true; Task.Run(async() => { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; var taskCompletionSource = new TaskCompletionSource <bool>(); await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { pivotGrid.OlapDataManager = vm.OlapDataManager; RootLayout.Children.Insert(0, pivotGrid); taskCompletionSource.SetResult(true); busyIndicator.IsBusy = false; }); await taskCompletionSource.Task; }); }
/// <summary> /// The event handler method is hooked when the radio button was clicked. /// </summary> /// <param name="sender">The radio button.</param> /// <param name="e">The event argument.</param> private void rdBtnRelationalData_Click(object sender, RoutedEventArgs e) { parentGrid.Children.RemoveAt(0); SfPivotGrid pivotGrid1 = new SfPivotGrid(); busyIndicator.IsBusy = true; Task t = Task.Run(async() => { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; var taskCompletionSource = new TaskCompletionSource <bool>(); await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { pivotGrid1.ItemSource = vm.ProductSalesData; // Adding rows to SfPivotGrid pivotGrid1.PivotRows.Add(new Syncfusion.PivotAnalysis.UWP.PivotItem() { FieldMappingName = "Product", TotalHeader = "Total" }); pivotGrid1.PivotRows.Add(new Syncfusion.PivotAnalysis.UWP.PivotItem() { FieldMappingName = "Date", TotalHeader = "Total" }); // Adding columns to SfPivotGrid pivotGrid1.PivotColumns.Add(new Syncfusion.PivotAnalysis.UWP.PivotItem() { FieldMappingName = "Country", TotalHeader = "Total" }); pivotGrid1.PivotColumns.Add(new Syncfusion.PivotAnalysis.UWP.PivotItem() { FieldMappingName = "State", TotalHeader = "Total" }); // Adding calculations to SfPivotGrid pivotGrid1.PivotCalculations.Add(new PivotComputationInfo() { FieldHeader = "Amount", FieldName = "Amount", Format = "C", SummaryType = SummaryType.DoubleTotalSum }); pivotGrid1.PivotCalculations.Add(new PivotComputationInfo() { FieldHeader = "Quantity", FieldName = "Quantity", Format = "#.##", SummaryType = SummaryType.Count }); parentGrid.Children.Insert(0, pivotGrid1); taskCompletionSource.SetResult(true); busyIndicator.IsBusy = false; }); await taskCompletionSource.Task; }); }
/// <summary> /// This event handler method is invoked when selecting the combo box item. /// </summary> /// <param name="sender">The combo box.</param> /// <param name="e">The event argument.</param> private void DisplayOptionChanged(object sender, RoutedEventArgs e) { ComboBox current = sender as ComboBox; SfPivotGrid pivotGrid = (this.pivotGrid2) as SfPivotGrid; string selectedOption = ((sender as ComboBox).SelectedItem as ComboBoxItem).Content.ToString(); int index = pivotGrid.PivotCalculations.Count > 1 && current.Name == "DisplayOptionBox1" ? 1 : 0; if (index == 0) { index = pivotGrid.PivotCalculations.IndexOf(pivotGrid.PivotCalculations.Where(x => x.FieldName == "Amount").FirstOrDefault()); } else { index = pivotGrid.PivotCalculations.IndexOf(pivotGrid.PivotCalculations.Where(x => x.FieldName == "Quantity").FirstOrDefault()); } if (selectedOption == "None") { pivotGrid.PivotCalculations[index].DisplayOption = DisplayOption.None; } else if (selectedOption == "All") { pivotGrid.PivotCalculations[index].DisplayOption = DisplayOption.All; } else if (selectedOption == "Calculations") { pivotGrid.PivotCalculations[index].DisplayOption = DisplayOption.Calculations; } else if (selectedOption == "Summaries") { pivotGrid.PivotCalculations[index].DisplayOption = DisplayOption.Summary; } else if (selectedOption == "GrandTotals") { pivotGrid.PivotCalculations[index].DisplayOption = DisplayOption.GrandTotals; } else if (selectedOption == "Summaries and Calculations") { pivotGrid.PivotCalculations[index].DisplayOption = DisplayOption.Calculations | DisplayOption.Summary; } else if (selectedOption == "Summaries and GrandTotals") { pivotGrid.PivotCalculations[index].DisplayOption = DisplayOption.Summary | DisplayOption.GrandTotals; } else if (selectedOption == "Calculations and GrandTotals") { pivotGrid.PivotCalculations[index].DisplayOption = DisplayOption.Calculations | DisplayOption.GrandTotals; } pivotGrid2.Refresh(); }
private void chk_ShowGroupingBar_Click(object sender, RoutedEventArgs e) { CheckBox current = e.OriginalSource as CheckBox; SfPivotGrid pivotGrid = this.PivotGrid1; CheckBox showGroupingBar = this.chk_ShowGroupingBar; CheckBox enableRowHeaderArea = this.chkBox_EnableRowHeader; CheckBox enableColumnHeaderArea = this.chkBox_EnableColumnHeader; CheckBox enableFilterHeaderArea = this.chkBox_EnableFilterHeader; CheckBox enableValueHeaderArea = this.chkBox_EnableValueHeader; if (enableRowHeaderArea.IsChecked == false && enableColumnHeaderArea.IsChecked == false && enableFilterHeaderArea.IsChecked == false && enableValueHeaderArea.IsChecked == false) { showGroupingBar.IsChecked = false; } }
/// <summary> /// The event handler method is hooked when the radio button was clicked. /// </summary> /// <param name="sender">The radio button.</param> /// <param name="e">The event argument.</param> private void rdBtnOlapDataSource_Click(object sender, RoutedEventArgs e) { parentGrid.Children.RemoveAt(0); SfPivotGrid pivotGrid = new SfPivotGrid(); busyIndicator.IsBusy = true; Task t = Task.Run(async() => { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; var taskCompletionSource = new TaskCompletionSource <bool>(); await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { pivotGrid.OlapDataManager = vm.OlapDataManager; parentGrid.Children.Insert(0, pivotGrid); taskCompletionSource.SetResult(true); busyIndicator.IsBusy = false; }); await taskCompletionSource.Task; }); }
/// <summary> /// Initializes the new instance of <see cref="CustomEditManager">CustomEditManager.</see>/> /// </summary> /// <param name="pg">The SfPivotGrid control.</param> public CustomEditManager(SfPivotGrid pg) : base(pg) { }
/// <summary> /// The event handler method is hooked when the radio button was clicked. /// </summary> /// <param name="sender">The radio button.</param> /// <param name="e">The event argument.</param> private void RelationalDataSource_Checked(object sender, RoutedEventArgs e) { RootLayout.Children.RemoveAt(0); pivotGrid = new SfPivotGrid { Margin = new Thickness(5) }; if (DeviceFamily.GetDeviceFamily() == Devices.Mobile && pivotGrid.ConditionalFormats != null) { pivotGrid.ConditionalFormats.Clear(); } pivotGrid.SetBinding(SfPivotGrid.ShowGroupingBarProperty, showGroupingBarBinding); pivotGrid.SetBinding(SfPivotGrid.EnableGroupingBarFilteringProperty, enableGroupingBarFilteringBinding); pivotGrid.SetBinding(SfPivotGrid.EnableGroupingBarRemovingProperty, enableGroupingBarRemovingBinding); pivotGrid.SetBinding(SfPivotGrid.EnableGroupingBarSortingProperty, enableGroupingBarSortingBinding); pivotGrid.SetBinding(SfPivotGrid.EnableRowHeaderAreaProperty, enableRowHeaderBinding); pivotGrid.SetBinding(SfPivotGrid.EnableColumnHeaderAreaProperty, enableColumnHeaderBinding); pivotGrid.SetBinding(SfPivotGrid.EnableFilterHeaderAreaProperty, enableFilterHeaderBinding); pivotGrid.SetBinding(SfPivotGrid.EnableValueHeaderAreaProperty, enableValueHeaderBinding); chk_EnableGroupingBarSorting.Visibility = Visibility.Visible; pivotGrid.SetBinding(SfPivotGrid.AllowMultiFunctionalSortFilterProperty, allowMultiFunctionalSortFilterBinding); chk_AllowMultiFunctionalSortFilter.Visibility = Visibility.Visible; busyIndicator.IsBusy = true; Task.Run(async() => { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; var taskCompletionSource = new TaskCompletionSource <bool>(); await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { pivotGrid.ItemSource = vm.ProductSalesData; // Adding rows to SfPivotGrid pivotGrid.PivotRows.Add(new Syncfusion.PivotAnalysis.UWP.PivotItem() { FieldMappingName = "Product", TotalHeader = "Total" }); pivotGrid.PivotRows.Add(new Syncfusion.PivotAnalysis.UWP.PivotItem() { FieldMappingName = "Date", TotalHeader = "Total" }); // Adding columns to SfPivotGrid pivotGrid.PivotColumns.Add(new Syncfusion.PivotAnalysis.UWP.PivotItem() { FieldMappingName = "Country", TotalHeader = "Total" }); pivotGrid.PivotColumns.Add(new Syncfusion.PivotAnalysis.UWP.PivotItem() { FieldMappingName = "State", TotalHeader = "Total" }); // Adding calculations to SfPivotGrid pivotGrid.PivotCalculations.Add(new PivotComputationInfo() { FieldHeader = "Amount", FieldName = "Amount", Format = "C", SummaryType = SummaryType.DoubleTotalSum }); pivotGrid.PivotCalculations.Add(new PivotComputationInfo() { FieldHeader = "Quantity", FieldName = "Quantity", Format = "#.##", SummaryType = SummaryType.Count }); RootLayout.Children.Insert(0, pivotGrid); taskCompletionSource.SetResult(true); busyIndicator.IsBusy = false; }); await taskCompletionSource.Task; }); }
/// <summary> /// The event handler is invoked when clicking the button. /// </summary> /// <param name="sender">The button.</param> /// <param name="e">The event argument.</param> private void btnExport_Click(object sender, RoutedEventArgs e) { SfPivotGrid pivot = parentGrid.Children[0] as SfPivotGrid; Button exportButton = e.OriginalSource as Button; FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedFileName = "Sample"; switch (exportButton.Content.ToString()) { case "Export To CSV": { ExportPivotGridToCsv csvExport = null; if (pivot.OlapDataManager == null) { csvExport = new ExportPivotGridToCsv(pivot); } else { csvExport = new ExportPivotGridToCsv(pivot.OlapDataManager.PivotEngine); } csvExport.ExportToDocument("Sample"); } break; case "Export To PDF": { ExportingGridStyleInfo gridStyleInfo = pivotGrid.GridStyleInfo ?? pivotGrid.GetExportingGridStyleInfo(); ExportPivotGridToPdf pdfExport = null; if (pivot.OlapDataManager == null) { pdfExport = new ExportPivotGridToPdf(pivot, gridStyleInfo); } else { pdfExport = new ExportPivotGridToPdf(pivot.OlapDataManager.PivotEngine, gridStyleInfo); } pdfExport.ExportToDocument("Sample"); } break; case "Export To Word": { ExportingGridStyleInfo gridStyleInfo = pivotGrid.GridStyleInfo ?? pivotGrid.GetExportingGridStyleInfo(); ExportPivotGridToWord wordExport = null; if (pivot.OlapDataManager == null) { wordExport = new ExportPivotGridToWord(pivot, gridStyleInfo); } else { wordExport = new ExportPivotGridToWord(pivot.OlapDataManager.PivotEngine, pivot.Layout, gridStyleInfo); } wordExport.ExportToDocument("Sample"); } break; case "Export To Excel": { ExportingGridStyleInfo gridStyleInfo = pivotGrid.GridStyleInfo ?? pivotGrid.GetExportingGridStyleInfo(); ExportPivotGridToExcel excelExport = null; if (pivot.OlapDataManager == null) { excelExport = new ExportPivotGridToExcel(pivot, gridStyleInfo, "xlsx", true); } else { excelExport = new ExportPivotGridToExcel(pivot.OlapDataManager.PivotEngine, gridStyleInfo, pivot.Layout, "xlsx", true); } excelExport.ExportToDocument("Sample"); } break; } }
/// <summary> /// This event handler method is invoked when selecting the check box. /// </summary> /// <param name="sender">The check box.</param> /// <param name="e">The event argument.</param> private void chkshowSubTotal_Click(object sender, RoutedEventArgs e) { CheckBox current = e.OriginalSource as CheckBox; SfPivotGrid pivotGrid = this.pivotGrid3; CheckBox showAllSubTotals = this.chkshowSubTotal; CheckBox showProductSubTotals = this.chkShowProductSubTotals; CheckBox showCountrySubTotals = this.chkShowCountrySubTotals; CheckBox showRowSubTotals = this.chkShowRowSubTotals; CheckBox showColumnSubTotals = this.chkShowColumnSubTotals; if (current?.Content != null) { int index; switch (current.Content.ToString()) { case "Show Product Subtotals": if (current.IsChecked == true) { index = pivotGrid.PivotRows.IndexOf( pivotGrid.PivotRows.FirstOrDefault(x => x.FieldMappingName == "Product")); if (index >= 0) { pivotGrid.PivotRows[index].ShowSubTotal = true; count--; } else { index = pivotGrid.PivotColumns.IndexOf( pivotGrid.PivotColumns.FirstOrDefault(x => x.FieldMappingName == "Product")); if (index >= 0) { pivotGrid.PivotColumns[index].ShowSubTotal = true; count--; } } } else { index = pivotGrid.PivotRows.IndexOf( pivotGrid.PivotRows.FirstOrDefault(x => x.FieldMappingName == "Product")); if (index >= 0) { pivotGrid.PivotRows[index].ShowSubTotal = false; count++; } else { index = pivotGrid.PivotColumns.IndexOf( pivotGrid.PivotColumns.FirstOrDefault(x => x.FieldMappingName == "Product")); if (index >= 0) { pivotGrid.PivotColumns[index].ShowSubTotal = false; count++; } } } pivotGrid.InternalGrid.InvalidateCells(); break; case "Show Country Subtotals": if (current.IsChecked == true) { index = pivotGrid.PivotColumns.IndexOf( pivotGrid.PivotColumns.FirstOrDefault(x => x.FieldMappingName == "Country")); if (index >= 0) { pivotGrid.PivotColumns[index].ShowSubTotal = true; count--; } else { index = pivotGrid.PivotRows.IndexOf( pivotGrid.PivotRows.FirstOrDefault(x => x.FieldMappingName == "Country")); if (index >= 0) { pivotGrid.PivotRows[index].ShowSubTotal = true; count--; } } } else { index = pivotGrid.PivotColumns.IndexOf( pivotGrid.PivotColumns.FirstOrDefault(x => x.FieldMappingName == "Country")); if (index >= 0) { pivotGrid.PivotColumns[index].ShowSubTotal = false; count++; } else { index = pivotGrid.PivotRows.IndexOf( pivotGrid.PivotRows.FirstOrDefault(x => x.FieldMappingName == "Country")); if (index >= 0) { pivotGrid.PivotRows[index].ShowSubTotal = false; count++; } } } pivotGrid.InternalGrid.InvalidateCells(); break; case "Show Row Subtotals": if (current.IsChecked == true) { pivotGrid.ShowRowSubTotals = true; if (showProductSubTotals.IsEnabled) { showProductSubTotals.IsChecked = true; } } else { pivotGrid.ShowRowSubTotals = false; if (showProductSubTotals.IsEnabled) { showProductSubTotals.IsChecked = false; } } break; case "Show Column Subtotals": if (current.IsChecked == true) { pivotGrid.ShowColumnSubTotals = true; if (showCountrySubTotals.IsEnabled) { showCountrySubTotals.IsChecked = true; } } else { pivotGrid.ShowColumnSubTotals = false; if (showCountrySubTotals.IsEnabled) { showCountrySubTotals.IsChecked = false; } } break; case "Show Subtotals": if (current.IsChecked == true) { pivotGrid.ShowSubTotals = true; showProductSubTotals.IsChecked = true; showCountrySubTotals.IsChecked = true; showRowSubTotals.IsChecked = true; showColumnSubTotals.IsChecked = true; count = 0; } else { pivotGrid.ShowSubTotals = false; showProductSubTotals.IsChecked = false; showCountrySubTotals.IsChecked = false; showRowSubTotals.IsChecked = false; showColumnSubTotals.IsChecked = false; count = 4; } pivotGrid.InternalGrid.InvalidateCells(); break; } if (count == 0) { showAllSubTotals.IsChecked = true; } else if (count < 4) { showAllSubTotals.IsChecked = null; } else if (count == 4) { showAllSubTotals.IsChecked = false; } } }