Hi,
I think I have found a bug in the IOlapViewModel (or in sample programs). I have used sample code from this forum and the sample programs in the blogs, online samples.
The issue is that is I expand all hierarchies from code-behind (code #1), then the columns/rows are not correctly identified (code #2) because the IsTotal is still set to True, even if everything is expanded.
Code #1:
public static void ExpandAllFlat(IOlapViewModel model) { var dataSource = model as DataSourceBase; for (int i = 0; i < dataSource.Rows.Count; i++) { IFilterViewModel fvm = dataSource.Rows[i] as IFilterViewModel; if (fvm != null && fvm.FilterMembers != null) { foreach (IFilterMember member in fvm.FilterMembers) { DrillInFlat(fvm, member); } } } for (int i = 0; i < dataSource.Columns.Count; i++) { IFilterViewModel fvm = dataSource.Columns[i] as IFilterViewModel; if (fvm != null && fvm.FilterMembers != null) { foreach (IFilterMember member in fvm.FilterMembers) { DrillInFlat(fvm, member); } } } // worker.RunWorkerCompleted += (s, e) => this.PivotGrid.DataSource.RefreshGrid(); ; // worker.RunWorkerAsync(this.PivotGrid.DataSource); model.RefreshGrid(); } private static void DrillInFlat(IFilterViewModel filterViewModel, IFilterMember filterMember) { if (filterMember.IsExpanded == false) { /* if (filterMember.Member.LevelDepth > 1) return; */ filterMember.IsExpanded = true; } foreach (IFilterMember member in filterMember.FilterMembers) { DrillInFlat(filterViewModel, member); } }
Code #2:
public static List<RowColumnIdentity> DetermineRows(IOlapViewModel olapVM, bool WantTotals, bool WantMeasures) { if (olapVM.Result.RowAxis.Tuples.Count == 0 || olapVM.Result.RowAxis.Tuples[0].Members.Count == 0) return null; int rowLevel = olapVM.Result.RowAxis.Tuples[0].Members[0].LevelDepth; bool dontAdd = false; int counter = 0; List<RowColumnIdentity> validRows = new List<RowColumnIdentity>(); for (int tupleCount = 0; tupleCount < olapVM.Result.RowAxis.Tuples.Count; tupleCount++) { var tuple = olapVM.Result.RowAxis.Tuples[tupleCount]; if (tuple.IsTotal == false || WantTotals == true) { List<RowColumnIdentity> tempRows = new List<RowColumnIdentity>(); dontAdd = false; for (int memberCount = 0; memberCount < tuple.Members.Count; memberCount++) { var member = tuple.Members[memberCount]; // if (member.LevelDepth == rowLevel) if (member.IsTotal == false || WantTotals == true) { if (member.ParentLevel != null) tempRows.Add(new RowColumnIdentity(counter, member.Caption, member.ParentLevel.ParentHierarchy.Name, member.IsTotal, member.LevelName == "")); else if (WantMeasures) tempRows.Add(new RowColumnIdentity(counter, member.Caption, member.Name, member.IsTotal, member.LevelName == "")); // tupleCount * (tuple.Members.Count) + memberCount } else { dontAdd = true; break; } } if (!dontAdd) { validRows.AddRange(tempRows); } } counter++; } return validRows; }
If I expand the node manually by pressing all the expanders on a PivotGrid that is linked to the datasource, then the determination of columns and rows works fine.
Can you please check this?
Thanks and best regards,
Tamas
Hi Todor,
You are right, I just overlooked something... I believe I checked the results too soon before the expansions were completed... sorry for wasting your time :)
Best regards,
Hi
I could not see anything wrong in the code. I made my test with flat data source and two buttons. When I clicked on first button, I executed code for expanding. After that I clicked on second button and I determinate the rows. The member.IsTotal property was set correct in both cases (code behind and manual expand).
What result do you expect for rows?
Todor