Sharepoint自定义筛选器Web部件

问题描述 投票:3回答:2

我想创建一个自定义Web部件,该部件具有多个过滤器Web部件,并且可以在运行时/设计时连接到Report Viewer Web部件(集成模式)。

我搜索了很多,但找不到让单个Web部件成为超过1个过滤器的提供者的方法。

比如说 -

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

解决方案目前已尝试过

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

问题:

即使我的自定义过滤器Web部件上显示2个连接选项,也只能添加一个。例如,如果我将Filter1(自定义Web部件)连接到Department,那么我无法再将它连接到Report Viewer 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 
}
sharepoint filter web-parts
2个回答
0
投票

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


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>");
            }
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.