创建数据透视图集合

时间:2011-06-14 18:41:53

标签: silverlight collections pivotviewer

我正在尝试创建一个JIT pivotviewer,我有点挣扎了。有人可以清楚我对如何动态创建cxml的困惑吗?还应该如何设置信息来请求它?我现在把它放在我的数据库里面,我是否需要为它加载创建一个xml文件,或者它可以直接从数据库中提取它吗?

1 个答案:

答案 0 :(得分:0)

要构建 JIT PivotViewer集合,首先要下载Microsoft构建的JIT example

在解决方案中查看,开始时最重要的一点是CollectionFactories项目。要使用数据库中的数据创建集合,您需要创建自定义CollectionFactory

您的自定义collectionfactory扩展了CollectionFactoryBase类:

class MyCustomCollection : CollectionFactoryBase

该类需要实现MakeCollection方法,此方法所要做的就是创建Collection类的实例并向其添加CollectionItems

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;
    }

现在要使用此集合并查看其实际操作,您需要在解决方案中为PivotViewer Silverlight应用程序(name of the collection)提供PivotServer

<强>的Default.aspx

<param name="initParams" value="cxml=MyImages.cxml" />
相关问题