Hi,
DataSourceBase.GenerateInitialItems is used to set intial values on Cube, Measures, Rows, and Columns properties.
I would like to subsequently change the Rows or Column property to a new value via code. However, when I assign the property a second time using GenerateInitialItems it appears to have no effect.
Thanks,
Gary
Hello Gary,
I have been looking into your issue and I can suggest you add the new dimensions directly in the DataSource Columns collection instead of using the method GenerateInitialItems:
var DataSource = this.xamPivotGrid.DataSource;
IHierarchy hierarchy = DataSource.Cube.Dimensions["Customer"].Hierarchies[0];
IFilterViewModel filterViewModel = DataSource.CreateFilterViewModel(hierarchy);
DataSource.Columns.Clear();
DataSource.Columns.Add(filterViewModel);
For additional reference please check the section “From Code-behind During Runtime” from the following link form our documentation:
http://help.infragistics.com/NetAdvantage/WPFDV/2011.2/CLR4.0/?page=xamPivotGrid_US_Assigning_Hierarchies_And_Measures.html
Please let me know if you need any additional assistance on this matter.
Thank you for your help! May I ask for your assistance with a slightly more complex example?
I would like to change the Rows at run-time to the following:
"[Date].[Calendar]{[Date].[Calendar].[Date].&[20080701], [Date].[Calendar].[Date].&[20080702]}"
I see how to specify the hierarchy, but I am not clear how to specify the item filter (the two dates).
Also, what event handler do you recommend I put this in so that I don't attempt to access the dimensions before they are loaded?
Thank you,
I have been investigating this and I can suggest you check the following link from our sample browser where you can try by yourself the filtering functionality and check the code behind that can help you achieve filtering from code
http://samples.infragistics.com/sldv/RunSamples.aspx?cn=pivot-grid#/pivot-grid/filtering
Also you can check the following forum thread which seems to be for the same thing:
http://community.infragistics.com/forums/p/64701/327373.aspx
Furthermore you can try to invoke this snippets in our LoadDimensionsCompleted event of your DataSource.
If you need any additional assistance on this matter please do not hesitate to ask.
I am just checking have you been able to resolve your issue? If you still need any assistance on the matter do not hesitate to ask.
I can see your concerns, so after some research, adding such built in method has been determined to be a new product idea. I have sent your product idea directly to our product management team. Our product team chooses new product ideas for development based on popular feedback from our customer base. Infragistics continues to monitor application development for all of our products, so as trends appear in requested features, we can plan accordingly.
Your reference number for this product idea is PI12040023.
Hello Elena,
I guess the sample provides sufficient guidance on the approach needed to resolve the issue, but I haven't attempted it because of the overwhelming complexity of the work effort.
Consider that any filter string can be applied with one line of code when setting the initial configuration of the pivot grid. Compare to the example that demonstrates doing the same after initialization--it has more than 200 lines of code that involves background processes, enumerating collections, wiring up event handlers, and parsing of data.
And that sample supports a specific case only. It will significant time to refactor this into a general purpose method that can accept the same string as GenerateInitialItems.
In the forum post link you provided, the responses seemed experimental and the original poster appears to have eventually gone with destroying and recreating the XmlaDataSource to solve the problem. In my case I cannot do this because I'll lose the current state of the pivot grid UI.
Regards,