I'm looking for an event that fires before the SSAS database gets queried. I want to be able to modify the Columns/Rows/Measures/Filter of the datasource programatically before every call to the database.
Example:User drags a measure into the grid to add it. Then the grid gets updated with the new data. I want to change the Columns/Rows/Measures/Filter that get sent before the grid updates with the new data.
I looked at pivotGrid.DataSource.PropertyChanged, but it fires a LOT on each action the user does. This would probably work, but doesn't seem to be what I'm looking for.
I looked at pivotGrid.DataContextChanged but it didn't fire when I was expecting.
Thanks for any help on this.
-BEP
Hi BEP,
Are you using an XmlaDataSource? If so then you can try using the InitXmlaMethod. This method is fired right before any queries are sent to the database. You can actually use this event to look at the SQL statement being sent as well. http://help.infragistics.com/NetAdvantage/Silverlight/2013.1/CLR4.0/?page=InfragisticsSL5.Olap.Xmla.v13.1~Infragistics.Olap.Xmla.XmlaDataSource~InitXmlaMethod_EV.html
Yes, we're using an XmlaDataSource and what you suggested was exactly what I needed. I handled this event, dug down in the sender object, and found what I needed.
Thank you for your holp.
I'm glad this was able to resolve your issue. Let me know if you have any further questions on this topic.
Thanks again, Rob. Between the 2 events you mentioned above, I have been able to do the basics of what I need for now.
You could use the ResultChanged event then. I did some testing and ResultChanged fires once right after the last InitXmlaMethod from the initial load. From here you can attach to the InitXmlaMethod and perform your filter code as desired.
Ideally, I think, what you should be doing is checking when the user tries to remove the filter you don't want removed. You can use the XmlaDataSource.Filters.CollectionChanged/ing event to determine if your filter has been removed. If it has then you can add it back.
With regards to the XAML formatting in the forums. I'm not really sure how other people go about getting their XAML formatted that way on the forums. I expect they are running the text through some tool that outputs the proper HTML that they can then use in a forum. I personally use http://www.manoli.net/csharpformat/ for my formatting as it's easy to use. The only thing missing, for me, is that the color formatting doesn't work on our forums. The rest of the formatting (indenting, spacing, etc.) seem to be preserved pretty well.
I removed the "Mark as Answer" in case that prevents any further action on the thread. I'll put it back after all the questions are resolved.
Thanks,-BEP
Hello again, Rob.
In my XmlaDataSource, I'm defining the database, cube, and some rows and columns and measures. My XamPivotDataSelector in my Expander is also connected to the same datasource as my PivotGrid.
My Xaml for this proof of concept app is in this thread:http://ko.infragistics.com/community/forums/t/83237.aspx
The XmlaDataSource_InitXmlaMethod gets called 10 times during startup because of the Pivot Grid and Selector being bound to the datasource. That means my code to manage a filter gets run that many times when the app starts up and I'd rather not have that happening.
What I'm trying to do is force a filter onto the person using the application. I need to programatically check to make sure the filter is there each time data is retrieved in case they've deleted the filter in the GUI. If it's not there, then I'll add it back. Or, delete the filter each time data is about to be fetched if it exists and always add it back. This is in case they changed the selected choices for that filter.
For the adding/subtracting filters, I was looking at these threads:http://ko.infragistics.com/community/forums/p/53796/278254.aspx#278254http://ko.infragistics.com/community/forums/t/60223.aspx
Using XmlaDataSource_InitXmlaMethod may actually work, but it gets called so many times at startup, I'd like to either not subscribe to the event until most of the stuff is completed on startup or flag my code in the event handler not to run until most of the app has finished the initial loading.
Do you know of a way to do this? Or, is there a better event to subscribe to that fires when everything is finished at the initial loading of the app? I could handle that event and then add my subscription to XmlaDataSource_InitXmlaMethod for subsequent calls.
ps. I posted Xaml in the other thread that I linked above using the code tags. How do I put Xaml in these forums that gets color-coded and indented like I see other people doing?