Click here to Skip to main content
Licence CPOL
First Posted 1 Feb 2011
Views 4,404
Bookmarked 1 time

Reloading a Collection in the PivotViewer

By | 1 Feb 2011 | Technical Blog
Reloading a Collection in the PivotViewer
A Technical Blog article. View original blog here.[^]

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

T. Champion

Web Developer
CDS
United States United States

Member

Follow on Twitter Follow on Twitter
I'm a software architect and Silverlight MVP with a major focus in Microsoft technologies. For the last several years I have focused on the Silverlight, WPF, and WP7 space. I also do quite a bit of work in Asp.net.
 
In addition, I own Champion Data Solutions, a custom software and consulting firm.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 1 Feb 2011
Article Copyright 2011 by T. Champion
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid