none
SharePoint Custom Connected Visual Webparts RRS feed

  • Question

  • Dear Experts,

    I have created a Visual Web Part (Provider web part) which inherits from IFilters and a consumer web part which consumes data from above Provider. Consumer web part has below code snippet to get data from Provider

     [ConnectionConsumer("Connection Filters")]
            public void ConsumerMethod(IFilters Provider)
            {
                strCode = Provider.Code;
                strFromDate = Provider.FromDate;
                strToDate = Provider.ToDate;
            }

    Above combination of Provider and Consumer web part works very well.

    Now question is, Can we use SharePoint OOB List Filter web parts as a provider for my custom consumer Visual web part, is this possible? Any references will be of great help.


    Thanks in Advance,

    Baba



    Thanks.... ________________ Baba (MCTS, MCPD)


    • Edited by Babasaheb Wednesday, September 4, 2019 7:28 AM
    Wednesday, September 4, 2019 7:23 AM

All replies

  • Hi,

    Check the demo in below thread.

    http://www.manvir.net/how-to-integrate-sharepoint-filter-webparts-with-custom-consumer-webpart/

    public class MyConsumerWebPart : System.Web.UI.WebControls.WebParts.WebPart
    {
    private ITransformableFilterValues filterWebPartsProvider;
    
    [Personalizable(PersonalizationScope.Shared)]
    public string FilterFieldName
    {  get;  set;  }
    
    [Personalizable(PersonalizationScope.Shared)]
    public string FilterFieldValue
    {  get; set; }
    
    //Use with OOB Filter Webparts
    [ConnectionConsumer(“Filter Consumer using FilterWebparts provider”, “FilterWebPartsConsumer”)]
    public void FilterWebPartsConsumer(ITransformableFilterValues Provider)
    {
    filterWebPartsProvider = Provider;
    }
    
    protected override void OnPreRender(EventArgs e)
    {
    EnsureChildControls();
    this.FilterFieldName = null;
    this.FilterFieldValue = null;
    
    if (filterWebPartsProvider != null)
    {
    this.FilterFieldName = filterWebPartsProvider.ParameterName;
    ReadOnlyCollection filterValues = filterWebPartsProvider.ParameterValues;
    if (filterValues != null)
    {
    foreach (string filterValue in filterValues)
    {
    this.FilterFieldValue += filterValue + “;”;
    }
    }
    }
    
    }
    }

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thursday, September 5, 2019 1:36 AM