Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

How to create custom filter web part with two or more filters

$
0
0

Hi,

I want to create a custom filter web part with two or more filters.  This web part will use to filter the data in another web part such as list view web part using web part connections. 

I don't want to use the OOTB filters.  I have tried creating web part by usingITransformableFilterValues interface.  This is working fine for one filter (status), how to add multiple filters?

The following is the code I am using, is there any other alternate way to create custom filters other thanITransformableFilterValues interface,  please provide me alternate options.

ToolboxItemAttribute(false)]
    public partial class FiltersVWP : WebPart,wsswebparts.ITransformableFilterValues
    {
        public List<string> GetStatus
        {
            get
            {
                List<string> statuses = new List<string>();
                if (chkCompleted.Checked == true)
                {
                    statuses.Add("Approved");
                }
                if (chkInProgress.Checked == true)
                {
                    statuses.Add("Pending");
                }

                if ((chkCompleted.Checked == false && chkInProgress.Checked == false) || 
                    (chkInProgress.Checked ==true && chkCompleted.Checked == true))
                {
                    return null;
                }
                return statuses;
            }
        }

        public bool AllowAllValue
        {
            get { return true; }
        }

        public bool AllowEmptyValue
        {
            get { return false; }
        }

        public bool AllowMultipleValues
        {
            get { return true; }
        }

        public string ParameterName
        {
            get { return "Status"; }
        }

        public ReadOnlyCollection<string> ParameterValues
        {
            get
            {
                List<string> values = this.GetStatus;
                return values == null ?
                    null :
                    new ReadOnlyCollection<string>(values);
            }
        }
        // Use the ConnectionProvider attribute to specify the method that
        // the Web Part framework should call to allow us to return an instance
        // of our ITransformableFilterValues interface.
        [ConnectionProvider("Status Filter", "ITransformableFilterValues", AllowsMultipleConnections = true)]
        public wsswebparts.ITransformableFilterValues SetConnectionInterface()
        {
            return this;
        }


    }

Recently Published Gallery, please rate and download
PowerShell Script for Creating Site Collection with Host Headers


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>