【问题标题】:ITransformableFilterValues interface with two or more parameters [SharePoint WebParts]具有两个或多个参数的 ITransformableFilterValues 接口 [SharePoint WebParts]
【发布时间】:2011-04-13 17:53:32
【问题描述】:

我使用 Sharepoint,并尝试使用多个参数连接 Web 部件。

我的问题是如何将多个参数从客户 Web 部件传递到另一个。

我可以通过在自定义 webpart 中实现 ITransformableFilterValues 接口来传递一个参数,我想要做的是传递多个参数(例如 MyIndex2)。

    // Configure interface

    public bool AllowEmptyValue
    {
        get { return false; }
    }
    public bool AllowAllValue
    {
        get { return true; }
    }
    public bool AllowMultipleValues
    {
        get { return true; }
    }
    public string ParameterName
    {
        get { return "MyIndex"; }   // Name of provided parameter
    }
    public ReadOnlyCollection<string> ParameterValues
    {
        get
        {
            EnsureChildControls();               
            List<string> MyFilterValues = new List<string>();
            if (MyFilterValue != null)
            {
                MyFilterValues.Add(MyFilterValue); //Provided value for another web-part
            }                           

            ReadOnlyCollection<string> result = new ReadOnlyCollection<string>(MyFilterValues);
            return result;
        }
    }


    [ConnectionProvider("MyIndex", "UniqueIDForRegionConnection", AllowsMultipleConnections = true)]
    public ITransformableFilterValues SetConnection()
    {
        return this;
    }

感谢您的帮助。对不起我的英语。

【问题讨论】:

    标签: sharepoint connection web-parts


    【解决方案1】:

    创建一个实现 ITransformableFilterValues 接口的类(而不是在您的 Web 部件类中实现它)

    class FilterValues : ITransformableFilterValues
    {
    ...
    }
    

    在您的主要 Web 部件中有

    FilterValues _fitler1;
    FitlerValues _filter2;
    

    (显然你也需要设置它们)

    添加方法以返回不同的过滤器,例如

    [ConnectionProvider("Filter 1", "UniqueIDForFilter1", 
    AllowsMultipleConnections = true)]
    public ITransformableFilterValues SetConnection()
    {
        return _fitler1;
    }
    
    [ConnectionProvider("Filter 2", "UniqueIDForFilter2", 
    AllowsMultipleConnections = true)]
    public ITransformableFilterValues SetConnection2()
    {
        return _fitler2;
    }
    

    【讨论】:

      【解决方案2】:

      确保报告参数处于可见模式。它对我有用。试试看

      谢谢 维韦克

      【讨论】:

        【解决方案3】:

        要修复您的代码修改如下:

        [aspnetwebparts.ConnectionProvider("Season", "idSeason", AllowsMultipleConnections = true)]
        public wsswebparts.ITransformableFilterValues SetConnectionSeason()
        {
            return filterValuesSeason;
        }
        
        [aspnetwebparts.ConnectionProvider("Category", "idCategory", AllowsMultipleConnections = true)]
        public wsswebparts.ITransformableFilterValues SetConnectionCategory()
        {
            return filterValuesCategory;
        }
        

        【讨论】:

          【解决方案4】:
           filterValuesYear = new FilterValues("Year", ddlYear.SelectedValue);
                  filterValuesQuarter = new FilterValues("Quarter", ddlQuarter.SelectedValue);
          
                   [ConnectionProvider("Year", "performance_year", AllowsMultipleConnections = true)]
              public ITransformableFilterValues SetConnectionYear()
              {
                  return filterValuesYear;
              }
          
              [ConnectionProvider("Quarter", "performance_monthly", AllowsMultipleConnections = true)]
              public ITransformableFilterValues SetConnectionQuarter()
              {
                  return filterValuesQuarter;
              }
          

          设置 WebPart 渲染的所有内容后,我看到两个连接都可用。 尝试将连接发送到 ReportViewerWebPart 窗口打开并获取 Null Ref 后(我尝试在需要时创建对象但它不起作用)

          谢谢 -萨马尔

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2023-03-05
            • 1970-01-01
            • 2016-01-06
            • 2019-09-24
            • 2012-10-01
            • 1970-01-01
            • 2010-11-27
            相关资源
            最近更新 更多