Is it possible to remove measures from "columns/rows" section in data selector?
I would like to set them visible in section "1" (under "measures" tree node) but I would like to remove them from section "2":
Hello,
I have been investigating this and have found a way for you to achieve your goal by iterating through the DataSource’s HierarchicalItems. Here is a code snippet you can use in the property changed event of the DataSource of your XamPivotDataSelector:
dataSelector.DataSource.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(DataSource_PropertyChanged);
…
void DataSource_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "Metadata")
HierarchicalItem rootItem = (sender as DataSourceBase).Metadata[0];
List<HierarchicalItem> theChosenOnes = new List<HierarchicalItem>();
foreach (HierarchicalItem item in rootItem.Items)
if ((item.Caption=="Units sold")||(item.Caption=="Amount of sale"))
theChosenOnes.Add(item);
}
if (theChosenOnes.Count>0)
foreach (var item in theChosenOnes)
rootItem.Items.Remove(item);
Please let me know if you require any further assistance on the matter.
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support
Is it possible to do this "automatically"? How can I get all measures from DataSource?
Ok, I found it. Your example is good enough :)
I found one problem when I'm changing pivot DataSource (with the same metadata). After change DataSource.PropertyChanged fires two times:1st) e.PropertyName == "MeasureGroup" - I can modify Metadata[0] 2nd) e.PropertyName == "Cube" - I can't modify Metadata (it is empty).Result - when pivot DataSource changed, measures in DataSelector are visible again.
Hello,What you mean saying you have changed the DataSource?Can you check:1. If you apply new instance as data source then are you listening for PropertyChanged event of the new instance?2. Are you assign the new data source to both pivot grid and selector?
Regards.Plamen.
Based on your questions I've found the problem. It was my fault. Thanks for your help!