我想创建一个自定义Web部件,该部件具有多个过滤器Web部件,并且可以在运行时/设计时连接到Report Viewer Web部件(集成模式)。
我搜索了很多,但找不到让单个网页部件成为超过1个过滤器的提供商的方法。
比如说 -
Report
接受2参数Department
和Region
。 Department
,另一个用于Region
)Department
和Region
Report
应在报表查看器Web部件到目前为止已尝试解决方案
ITransformableFilterValues
ConnectionProvider
属性,并返回下拉控件的实例问题:
即使我的自定义过滤器Web部件上显示了2个连接选项,也只能添加一个。
例如,如果我将Filter1
(自定义网络部分)与Department
相关联,那么我将无法再将其与Report Viewer
网络部分相关联。
我的网络部分有这样的方法:
[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
}
答案 0 :(得分:0)
我做了类似的事情。这可能有助于指明您正确的方向。我使用表单库中的数据来创建详细的报告。我使用报告服务并使用Web服务连接到sharepoint。 http://server/_vti_bin/Lists.asmx。我使用的报告参数是项目ID或GUID。然后我配置了我的报告查看器。在表单库中,我使用JavaScript覆盖上下文菜单以添加“查看报告”。在报告页面上,我使用了一个查询字符串过滤器来从网址中获取项目ID。
答案 1 :(得分: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> <i>"(empty)"/null</i></div>");
}
else if (v.Length == 0)
{
writer.Write("<div> <i>empty string</i></div>");
}
else
{
writer.Write("<div> " + v + "</div>");
}
}
}
else
{
writer.Write("<div>No filter specified (all).</div>");
}
}
else
{
writer.Write("<div>Not connected.</div>");
}
writer.Write("<hr>");
}
}
}
}