Tag Archive: JIT Collection

After playing with Pivot Viewer for long time, I decided to take one more step of going towards a decentralized approach i.e. storing data in different servers. So, I created 3 servers, one for images another for data (about facets) and one server for Pivot Viewer JIT Collection generation. Everything was well set and all communication working fine and suddenly I couldn’t see images any more in the Pivot Viewer. I checked all the images that my images were accessible from my machine, the data was going to the JIT server properly and also checked all the possible options where an exception could be raised and I didnt find anything…and still no images!

Then I compared the CXML files from the version before and this new setup and I found out that there was no information about the images and I was really pissed…as to what in the world went wrong? Then it struck into my mind to try an access the images on the server where the CXML is being generated and BINGO! The error was even though the images existed and were accessible from the my machine…they were not accessible on the JIT server and as soon as I enabled the access of the images on this server, the images started to show up on the pivot viewer as well.

Come to think about it, its pretty logical and I should have known that this would happen but I didn’t realize until I faced the issue. And sharing this, might help some other poor soul like mine was for the last 2 days.


Pivot Viewer Collection Caching

When you are using dynamic collections with PivotViewer i.e. JIT collections generated using the PivotServerTools, there comes a situation when the Pivot Viewer stops taking the fresh data from the server. This is because the Pivot Viewer caches the collection, so when you reload the collection again (in the same session), it doesn’t ask the JIT server for the cxml again and instead uses the cxml from the cache. This is good in terms of the performance however it’s bad if your data keeps on updating at the server and you are not able to reflect the latest data in your collection. What you should know is that the PivotViewer caches the collection based on the URL that you pass in the PivotViewer’s LoadCollection method, so if you call the method:

PivotViewer.LoadCollection(“url”, “viewerstate”);

again and again without changing the url parameter, only for the first call data will be fetched from your server, for all subsequent calls PivotViewer will take the collection from the cache. To avoid this, you have to keep changing the URL, whenever you call the above method. The best way to do it, is to add a query string parameter which you may/may not use and update it every time you load the collection. You can do something like below:

PivotViewer.LoadCollection(“url”+ “?guid=”+Guid.NewGuid(), “viewerstate”);

this adds a new query string parameter “guid” to your url who’s value change every time you load the collection and since it’s a different url, PivotViewer doesn’t find the collection in its cache and hence sends a call to the JIT server to get the new collection. Therefore, you will always see fresh data in your collection but what you should keep in mind is that this will degrade the performance of the PivotViewer (but only at the time of loading), so what you can do as a further tweak is only change the guid parameter when you need fresh data in your collection and in all the other cases you can use the url with the same guid parameter which will help in keeping the performance of the PivotViewer intact, this tweak will be a boon if your JIT server takes time for generating the collection and the data is not updated always.

Happy Coding 🙂

I have been working around with the Silverlight Pivot Viewer for long time now and I have noticed that whenever I use a JIT collection I dont see Description in the facet panel but when I use a static collection, Description is available. First I thought maybe description facet is not allowed in JIT collections but then I remembered that the Collection class constructor does ask for Description in its parameter, this made my curious and I started dive into the code of PivotServerTools Project and I found that there’s no place in the code where this Description is used apart from when creating the default item images. After a lot of searching I was able to find a solution using which Description can be made visible. To do so, follow the below steps:

1. Go to the PivotServerTools project.
2. Open the Internal folder.
3. There you’ll see a “CxmlSerializer” class, this class is used when the method Collection.ToCXML() is invoked, which is done by the Pivot Viewer. Open this class and navigate to the method “MakeItemContent”. In this method add the following line:

if (!string.IsNullOrEmpty(item.Description)){
	yield return new XStreamingElement(Xmlns + "Description", item.Description);

This way Description will start showing up in the Facet panel of every collection provided you specified a value for it in the Item’s collection class constructor.