Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Reloading a Collection in the PivotViewer

0.00/5 (No votes)
1 Feb 2011 1  
Reloading a Collection in the PivotViewer

I discovered an interesting tidbit when working on the code for my upcoming PivotViewer series (you can find the code on CodePlex at http://tonyc.me/pvles). It seems that you can't reload the current collection from the server.

First off, I noticed an absence of any sort of “Reload” or “Refresh” method to make this process easy. So I began to do a little research and tried the following:

To begin with, I simply called LoadCollection() and passed in the Uri. I promptly noticed that nothing happened. Hmmm… So on to the next step.

If you are familiar with the LoadCollection() method, then you might have noticed a default viewerState as the second argument. The viewer state is a lot of fun and I will dig into that in another post. However, for this issue, I was hoping changing up the viewer state would fire off a refresh. Nope. Strike two.

So now I decided to bring out the big guns, .NET Reflector by Red-Gate, to see if I could see what is going on. By the way, it’s a great tool to have as a .NET developer and I highly recommend it. So I did a little digging, and what do you know, I found the issue.

The PivotViewer is simply trying to be efficient really. When you pass in a Uri, it compares it with the existing collection to see if it is the same. If it is, it simply does not do a reload to keep from having to make another trip to the server to update the data and interrupt the user’s experience.

Ah ha! So now we just need to change the Uri, right? My first attempt was to simply add a hash tag with a counter. So my attempts looked something like this:

First attempt:

Second attempt:

Well, it seems that the PivotViewer was smarter than me and realized it was the same Uri and ignored the new Uri. So I took it a step further and found a working solution. It seems that it will consider a change in the querystring as a new Uri. So the final working solution looks like this:

First attempt:

Second attempt:

Bingo! I nicely reloaded collection.

If you find yourself needing to refresh the collection of the PivotViewer and can't seem to make it refresh, then this should get you up and running.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here