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.