3

我想创建一个自定义 Web 部件,它具有超过 1 个筛选器 Web 部件,并且可以在运行时/设计时连接到报表查看器 Web 部件(集成模式)。

我为此进行了很多搜索,但找不到一种方法来让单个 Web 部件成为多个过滤器的提供者。

比如说——

  1. Report接受 2 个参数DepartmentRegion
  2. 我想将这两个参数与具有两个下拉菜单的单个 Web 部件连接起来(一个用于Department,一个用于Region
  3. 下拉菜单中的值都应传递给DepartmentandRegion
  4. Report应在报表查看器 Web 部件中呈现

到目前为止尝试过的解决方案

  1. 创建一个添加两个自定义下拉列表的 Web 部件
  2. 实现的自定义下拉类ITransformableFilterValues
  3. 在 web pat 上有 2 个方法,每个方法都有ConnectionProvider属性并返回下拉控件的实例

问题:

即使我的自定义筛选器 Web 部件上显示了 2 个连接选项,也只能添加一个。例如,如果我连接Filter1(自定义 Web 部件)Department然后我无法再次将它连接到Report ViewerWeb 部件。

我的 Web 部件有这样的方法:  

[ConnectionProvider("Departmet", "UniqueIDForDept", AllowsMultipleConnections = true)] 
public ITransformableFilterValues ReturnCity() 
{ 
    return dropDownDepartment; // It implemets ITransformableFilterValues 
} 

[ConnectionProvider("Region", "UniqueIDForRegion", AllowsMultipleConnections = true)] 
public ITransformableFilterValues ReturnMyRegionB() 
{ 
    return dropDownRegion; //It implemets ITransformableFilterValues 
}
4

2 回答 2

0

不知道你是否能够解决你的问题..

实际上我尝试过AllowsMultipleConnections = true并且效果很好:

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;

using Microsoft.SharePoint;


using aspnetwebparts = System.Web.UI.WebControls.WebParts;
using Microsoft.Office.Server.Utilities;
using wsswebparts = Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Portal.WebControls;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using Microsoft.SharePoint.Utilities;

namespace FromMultiSource
{
    [Guid("a0d068dd-9475-4055-a219-88513e173502")]
    public class MultiSource : aspnetwebparts.WebPart
    {
        List<wsswebparts.IFilterValues> providers = new List<wsswebparts.IFilterValues>();
        public MultiSource()
        {
        }

        [aspnetwebparts.ConnectionConsumer("Multiple Source Consumer", "IFilterValues", AllowsMultipleConnections = true)]
        public void SetConnectionInterface(wsswebparts.IFilterValues provider)
        {
            this.providers.Add(provider);
            if (provider != null)
            {
                List<wsswebparts.ConsumerParameter> l = new List<wsswebparts.ConsumerParameter>();
                l.Add (new wsswebparts.ConsumerParameter ("Value", wsswebparts.ConsumerParameterCapabilities.SupportsMultipleValues | Microsoft.SharePoint.WebPartPages.ConsumerParameterCapabilities.SupportsAllValue));
                provider.SetConsumerParameters(new ReadOnlyCollection<wsswebparts.ConsumerParameter>(l));
            }
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // TODO: add custom rendering code here.
            // Label label = new Label();
            // label.Text = "Hello World";
            // this.Controls.Add(label);
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            base.RenderContents(writer);
            this.EnsureChildControls();
            foreach (wsswebparts.IFilterValues provider in this.providers)
            {
                if (provider != null)
                {
                    string prop = provider.ParameterName;
                    ReadOnlyCollection<string> values = provider.ParameterValues;
                    if (prop != null && values != null)
                    {
                        writer.Write("<div>" + SPEncode.HtmlEncode(prop) + ":</div>");
                        foreach (string v in values)
                        {
                            if (v == null)
                            {
                                writer.Write("<div>&nbsp;&nbsp;<i>&quot;(empty)&quot;/null</i></div>");
                            }
                            else if (v.Length == 0)
                            {
                                writer.Write("<div>&nbsp;&nbsp;<i>empty string</i></div>");
                            }
                            else
                            {
                                writer.Write("<div>&nbsp;&nbsp;" + v + "</div>");
                            }
                        }
                    }
                    else
                    {
                        writer.Write("<div>No filter specified (all).</div>");
                    }

                }
                else
                {
                    writer.Write("<div>Not connected.</div>");
                }

                writer.Write("<hr>");
            }
        }
    }
}
于 2009-08-06T21:17:56.853 回答
0

我做了类似的事情。这可能有助于为您指明正确的方向。我使用表单库中的数据来创建详细报告。我使用报告服务并使用 Web 服务连接到共享点。http://server/_vti_bin/Lists.asmx。我使用的报告参数是项目 ID 或 GUID。然后我配置了我的报告查看器。在表单库中,我使用 JavaScript 覆盖上下文菜单以添加“查看报告”。在报告页面上,我使用查询字符串过滤器从 url 中获取项目 ID。

于 2008-12-04T19:09:50.807 回答