Current filter:
                                You should refresh the page.
                                  • Hello,

                                    I have a PivotTable with a binded chart. This works perfect.
                                    With tabs I want to rearrange the PivotTable and therefore the chart.
                                    This also works, except the collapsing. Once a field is expanded, it will remain expanded, even if I use collapseAll() or the attribute "expanded: false" in the fieldsettings (see Code below).

                                    [C#]
                                    <div id="pivotgrid-demo"> @{ var tabs = new[] { new { id = 0, text = "Standard", fileName="Ausschreibungen"}, new { id = 1, text = "Einstellung 1", fileName="Ausschreibungen1"} }; } @(Html.DevExtreme().Chart() .Title(t => t .Text("Anzahl der Ausschreibungen") .Subtitle(s => s.Text("Standard")) ) .ID("pivotgrid-chart") //.Palette(VizPalette.Ocean) .CommonSeriesSettings(s => s.Type(SeriesType.Bar)) .Tooltip(t => t.Enabled(true).CustomizeTooltip("customize_tooltip")) .Size(s => s.Height(300)) .Export(e => e.Enabled(true)) .Legend(l => l .VerticalAlignment(VerticalEdge.Top) .HorizontalAlignment(HorizontalAlignment.Center) .ItemTextPosition(Position.Right) ) .AdaptiveLayout(l => l.Width(450))) @(Html.DevExtreme().Tabs() .ID("tabs-container") .DataSource(tabs) .SelectedIndex(0) .OnItemClick("tabs_itemClick") ) @(Html.DevExtreme().PivotGrid<DocumentDataViewModel>() .ID("pivotgrid") .AllowSortingBySummary(true) .AllowSorting(true) .AllowFiltering(true) .AllowExpandAll(true) .ShowBorders(true) .ShowColumnGrandTotals(true) .ShowRowGrandTotals(true) .ShowRowTotals(true) .ShowColumnTotals(true) .FieldChooser(c => c.Enabled(true).Height(600)) .Scrolling(s => s.Mode(PivotGridScrollingMode.Virtual)) .Export(e => e.Enabled(true).FileName("Ausschreibungen")) //.StateStoring(st => st.Enabled(true)) .DataSource(d => d .Store(s => s.WebApi().Controller("PivotGridData")) .Fields(fields => { fields.AddFor(m => m.Arbeitgebername) .Width(200) .Area(PivotGridArea.Row) //.SortBySummaryField("Total"); .SortOrder(SortOrder.Asc); fields.AddFor(m => m.WGS) .Width(200) .Selector(@<text> function(data) { return data.WGS.join("\n"); } </text>) .Area(PivotGridArea.Row); fields.AddFor(m => m.Veroeffentlicht) .Area(PivotGridArea.Column); fields.Add() .GroupName("Date") .GroupInterval(PivotGridGroupInterval.Month) .Visible(true); fields.Add() .Area(PivotGridArea.Data) .Caption("Ausschreibungen") .SummaryType(SummaryType.Count); }) ).OnContentReady("bind_chart") ) </div> <script> DevExpress.localization.locale(navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage); function customize_tooltip(args) { return { html: "<div class='textCenter'>" + args.seriesName + "</br>" + args.valueText + " Ausschreibungen</div>" }; } function bind_chart(e) { e.component.bindChart($("#pivotgrid-chart"), { dataFieldsDisplayMode: "splitPanes", alternateDataFields: false }); } function setPivotTableTo_Standard(pivotGrid) { pivotGrid.getDataSource().field("Veroeffentlicht", { area: "column", dataType: "date", areaIndex: 0 }); // This also does not work. Once a field is expanded, it will remain expanded also if you use "expanded: false" // pivotGrid.getDataSource().field("Veroeffentlicht", { area: "column", dataType: "date", areaIndex: 0, expanded: false }); // pivotGrid.getDataSource().field("Arbeitgebername", { area: "row", width: 200, areaIndex: 0, expanded: true }); pivotGrid.getDataSource().field("Arbeitgebername", { area: "row", width: 200, areaIndex: 0 }); pivotGrid.getDataSource().field("WGS", { area: "row", areaIndex: 1 }); pivotGrid.getDataSource().field("EU", { area: "row", areaIndex: 2 }); pivotGrid.getDataSource().field({ area: "data", summaryType: "count" }); // Here is the problem, once a field is expanded, it will remain expanded, also if you use collapseAll() pivotGrid.getDataSource().collapseAll("Veroeffentlicht"); pivotGrid.getDataSource().expandAll("Arbeitgebername"); } function setPivotTableTo_Einstellung1(pivotGrid) { pivotGrid.getDataSource().field("Arbeitgebername", { area: "column", width: 200, areaIndex: 0 }); // This also does not work. Once a field is expanded, it will remain expanded also if you use "expanded: false" pivotGrid.getDataSource().field("Arbeitgebername", { area: "column", width: 200, areaIndex: 0, expanded: false}); pivotGrid.getDataSource().field("Veroeffentlicht", { area: "row", dataType: "date", areaIndex: 0, expanded: true}); pivotGrid.getDataSource().field("Veroeffentlicht", { area: "row", dataType: "date", areaIndex: 0 }); pivotGrid.getDataSource().field("EU", { area: "row", areaIndex: 1 }); pivotGrid.getDataSource().field("WGS", { area: "row", areaIndex: 2 }); pivotGrid.getDataSource().field({ area: "data", summaryType: "count" }); // Here is the problem, once a field is expanded, it will remain expanded, also if you use collapseAll() pivotGrid.getDataSource().collapseAll("Arbeitgebername"); pivotGrid.getDataSource().expandAll("Veroeffentlicht"); } function tabs_itemClick(e) { var pivotGrid = $("#pivotgrid").dxPivotGrid("instance"); pivotGrid.getDataSource().state({}); // set exportfilename for pivotgrid for each setting pivotGrid.option("export.fileName", e.itemData.fileName); // set subtitle of chart and exportfilename for chart for each setting var chart = $("#pivotgrid-chart").dxChart("instance"); chart.option("title.subtitle", e.itemData.text); chart.option("export.fileName", e.itemData.fileName); switch (e.itemData.id) { case 0: setPivotTableTo_Standard(pivotGrid); break; case 1: setPivotTableTo_Einstellung1(pivotGrid); break; default: setPivotTableTo_Standard(pivotGrid); } pivotGrid.getDataSource().load(); } </script>

                                    Is this a Bug or am I doing something wrong?

                                    Greetings,
                                    André

                                2 Solutions

                                Creation Date Importance Sort by

                                Hi,

                                If you change filed attributes ("area"), it is necessary to reload the underlying datsource via the load method. In this scenario, data will be refreshed automatically and all fields will be collapsed. So, you do no need to collapse them manually. I have prepared a small code example that illustrates this approach: https://codepen.io/anon/pen/BMxKBw.

                                Thanks,
                                Alessandro

                                • Customer36680 02.11.2019

                                  Hi,

                                  I've edited your example to describe my problem better:
                                  https://codepen.io/anon/pen/YBLGXb

                                  I've added a second button. These two buttons rearrange the columns and rows in the pivotgrid.
                                  In the first setting (Button "Test") the column "region" should be expanded (and only this column).
                                  In the second setting (Button "Test2") the column "date" should be expanded (and only this column).
                                  But this does not realy work in my example (https://codepen.io/anon/pen/YBLGXb).

                                  Any ideas?

                                  Thanks,
                                  André

                                • Alessandro (DevExpress Support) 02.12.2019

                                  Hi,

                                  Thank you for pointing out this behavior. I reproduced it on our side and will discuss it with the team. We will contact you once we have any results. In the meantime, as a workaround, you can define a separate grouped field explicitly and expand/collapse it separately:

                                  [JavaScript]
                                  { groupName: "date", groupInterval: "year", name: "year" },

                                  Here is the modified sample: https://codepen.io/anon/pen/bzKNeE?editors=1010. If you need to expand multiple grouping levels, it is necessary to define all these levels as separate fields and expand them sequentially. Once we fix the issue, the expandAll method will expand all these groups automatically.

                                  You will be informed once we have any progress in the context of this ticket. Thank you for your time and cooperation.