No New WebPart Properties when Extending the CQWP!
-
16-10-2019 - |
Pergunta
I'm adding some functionality to the ContentQueryWebPart by inheriting from ContentByQueryWebPart... but when I try and add a new WebPart Property, the actual field does not show up when I edit the webpart! Has anyone else tried this?
Here is an example of a property I am trying to add:
[WebBrowsable(true), Personalizable(PersonalizationScope.Shared), WebDisplayName("Page Filter Field"),
WebDescription("Enter the Page Field name which the CQWP will filter on"),
SPWebCategoryName("CategoryConfigureQuery")]
public string PageFilterField
{
get
{
return _pageFilterField;
}
set
{
_pageFilterField = value;
}
}
Solução
You need to add a customised ToolPart for your property
public class CustomWebPart : ContentByQueryWebPart {
public override ToolPart[] GetToolParts() {
List<ToolPart> result = new List<ToolPart>(base.GetToolParts());
result.Add(new YourCustomToolPart());
return result.ToArray();
}
}
And for the ToolPart see here
http://msdn.microsoft.com/en-us/library/dd584178(office.11).aspx
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange