I'm trying to create a JIT pivotviewer and I have been kinda struggling a bit. Could someone clear my confusion on how the cxml is dynamically created? Also how should the information be set up for me to request it? I currently have 开发者_开发知识库it sitting inside of my database, do I need to create an xml doc for it to load from or can it pull it straight from the db?
For building a JIT PivotViewer collection you start by downloading the JIT example built by Microsoft.
Look around in the solution, when getting started the most important bit is the CollectionFactories
project. To create a collection using data from your database you need to create your custom CollectionFactory
.
Your custom collectionfactory extends the CollectionFactoryBase
class:
class MyCustomCollection : CollectionFactoryBase
the class needs to implement the MakeCollection
method, all this method has to do is create an instance of Collection
class and add CollectionItems
to it.
public override PivotServerTools.Collection MakeCollection(CollectionRequestContext context) {
return MakeCollection();
}
private static PivotServerTools.Collection MakeCollection() {
PivotServerTools.Collection collection = new PivotServerTools.Collection();
collection.Name = "MyImages";
ItemImage[] fileList = ImageListFromDatabase();
foreach (ItemImage image in fileList) {
collection.AddItem(image.Name, image.ImageUrl.ToString(), image.Description, image, null);
}
return collection;
}
Now to use this collection and see it in action, you need to provide the name of the collection
for the PivotViewer Silverlight application (PivotServer
) in the solution:
default.aspx
<param name="initParams" value="cxml=MyImages.cxml" />
精彩评论