ITransformableFilterValues interface with two or more parameters [SharePoint WebParts]

断了今生、忘了曾经 提交于 2019-12-10 17:21:04

问题


I working with Sharepoint, and I try to connect web-parts with multiple parameters.

My question is how do I pass more than one parameter from a custome web part to another.

I am able to pass one parameter by implementing the ITransformableFilterValues interface in the custom webpart , what I want to do is pass more than one parameter (MyIndex2 for example).

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

Thanks for help. And sorry for my English.


回答1:


Create a class that implements the ITransformableFilterValues interface (rather than implementing it in your web part class)

class FilterValues : ITransformableFilterValues
{
...
}

In your main web part have

FilterValues _fitler1;
FitlerValues _filter2;

(obviously you will need to set them up too)

Add methods to return the different filters e.g.

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

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



回答2:


Make sure the report parameters are in Visible mode. It worked for me. Give it a try

Thanks Vivek




回答3:


To fix your code modify as below:

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

After setting up every thing WebPart Renders, i see Both Connection is available. After trying to send Connection to ReportViewerWebPart Window opens and getting Null Ref (I tried creating object as when it is needed but its not working)

Thanks -Samar



来源:https://stackoverflow.com/questions/3735844/itransformablefiltervalues-interface-with-two-or-more-parameters-sharepoint-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!