gial
gial

Reputation: 41

ITransformableFilterValues interface with two or more parameters [SharePoint WebParts]

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.

Upvotes: 4

Views: 6928

Answers (4)

samar
samar

Reputation: 1

 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

Upvotes: 0

Giu
Giu

Reputation: 1

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

Upvotes: 0

V.B
V.B

Reputation: 1211

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

Thanks Vivek

Upvotes: 0

Ryan
Ryan

Reputation: 24442

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

Upvotes: 3

Related Questions