A web part with a custom property associated with a select field from a content type?

I am trying to create a custom property for WebPart. The custom property must be a dropdown with a selection coming from the Select column of the content type. Is it possible?

+2


source to share


2 answers


You have two options:

1) If your choice never changes, you can hard-code the enum with these values ​​and use it as the datatype for your custom property. SP will automatically generate a drop.



2) If you cannot hardcode the values ​​then you should implement a so called editor panel where you can code the UI to handle the custom property entry

+1


source


You cannot bind data directly to a content type column as it does not exist as in a bound form, only as XML partitioning by the content type itself.

Better to specify the column as a search and bind to the list directly. However, this won't work well when you only need one view across multiple websites or site collections.



In this case, create a list in a configuration site such as http: // intranet / sites / config and code a control to bind to that list. Then use the control in the web part and in the custom field control of the content type.

A bit of work, but worth it if you want control over SharePoint (versioning, security, etc.), access to search content, and a single (mutable) data source throughout your site.

+1


source







All Articles