Compile filter webpart-Filter list content

Source: Internet
Author: User
First look Code :

Using System;
Using System. runtime. interopservices;
Using System. Web. UI;
Using System. Web. UI. webcontrols. webparts;
Using System. xml. serialization;
Using System. collections;
Using Microsoft. SharePoint;
Using Microsoft. Sharepoint. webcontrols;
Using Microsoft. Sharepoint. webpartpages;
Using System. componentmodel;

Namespace Mypart
{
[GUID ( " 9eb18c96-ce55-4a8b-8e08-e6db886c0320 " )]
Public   Class Mypart: Microsoft. Sharepoint. webpartpages. webpart, iwebpartparameters
{
Public Mypart ()
{
This . Exportmode = Webpartexportmode. All;
}

Protected Override VoidRender (htmltextwriter writer)
{
Writer. Write ("Hello, world!");
}

# region Other connecton interfaces
/// [connectionconsumer (" iwebpartfield "," iwebpartfield ")]
// Public void setobj (iwebpartfield f)
/// {< br> /// }

// [connectionconsumer ("iwebpartrow ", "iwebpartrow")]
// Public void setobj (iwebpartrow f)
/// {< br> /// }

//[Connectionconsumer ("iwebparttable", "iwebparttable")]
//Public void setobj (iwebparttable F)
//{
//}
# Endregion

[Connectionprovider ( " Iwebpartparameters " , " Iwebpartparameters " )]
Public Iwebpartparameters provideriwebpartparameters ()
{
Return   This ;
}
# Region Iwebpartparameters Member
Public   Void Getparametersdata (parameterscallback callback)
{
// Here, the filter criteria are returned Based on the _ schema field name.
Idictionary DIC =   New Hashtable ();
// Dic. Add ("keyword", this. Keyword );
Dic. Add ( " Linktitle " , " Xxx " ); // Filter by title
Callback (DIC );
}
Public System. componentmodel. propertydescriptorcollection Schema
{
Get  
{
Return _ Schema;

// Propertydescriptorcollection properties =
// Typedescriptor. getproperties (this, new attribute [] {New webbrowsableattribute ()});
// Return properties;
}
}
Private Propertydescriptorcollection _ Schema;
Public   Void Setconsumerschema (system. componentmodel. propertydescriptorcollection schema)
{
_ Schema = Schema;
}
# Endregion
}
}

Drag the preceding webpart into oneNotificationThe allitems. ASPX page of the list. In editing mode, select Edit> connection> iwebpartparameters send Object> current list,
You can see the effect: the list is only displayed for projects with the title of XXX.

In Moss, there are many filters for webparts that can be used to filter the content of the list, which are not available in WSS. How are these filters developed?
It's easy, as long as the webpart filter implements iwebpartparameters.
  Public   Void Setconsumerschema (system. componentmodel. propertydescriptorcollection schema)
{
_ Schema=Schema;
}

This method sets the filter parameters of the target webpart (usually a listviewwebpart.

Public System. componentmodel. propertydescriptorcollection Schema
{
Get  
{
Return_ Schema;
}
}

This attribute returns the filter parameters provided by the filter.

  Public   Void Getparametersdata (parameterscallback callback)
{
// Here, the filter criteria are returned Based on the _ schema field name.
Idictionary DIC =   New Hashtable ();
// Dic. Add ("keyword", this. Keyword );
Dic. Add ( " Linktitle " , " Xxx " ); // Filter by title

Callback (DIC );
}

This method sets the filter value so that the filtered List displays only the questions with the title XXX.

The filter can filter a field in the list (multiple fields should also be fine ). However, it is a pity that the filter can only achieve exact matching and filtering, and fuzzy query is not allowed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.