There have been some great ideas posted in the comments section of this blog, particularly to the
following posting:
Leveraging the use of Site Columns – Part II
One of the blog readers: Katy, was kind enough to share a common “featurette” when using Site Columns, by default the
hyperlink is enabled pointing back to the location of the Lookup List Item. While for some in
some instances this is not a huge problem, it can be annoying for the end user.
With this suggestion in mind, looked around through the User Interface and was not able to
satisfactorily find a simple way to find a solution to this issue. After spending quite some time
decided to just go ahead and find a solution through custom development. Decided to create a
Custom Field Type, for those who are not familiar with this concept I recommend the following links:
By developing a Custom Field Type, I was able to get the UserControl to inherit from the BaseFieldControl. This allowed
for the display to be not done as a Link. More importantly, this could be modified to inherit from the many choices available
for SPFieldxxx. Another possibility, could be the use of a different type of control like a Multi-Choice ListBox.
After all was said and done this is what the code in the CreateChildControls looked like:
The magic happens in those12 lines of code that instantiate the Site Column, track back to the
Lookup Web, List and Field. Ending with the population of the DropDown with the ListItems of
the SharePoint List.
Creating a Column based on the new Custom Field Type
The Custom Field Type in Action
What did the end result look like?
Notice that there is no HyperLink and that a color has been set just to add a little twist.
While this is not a full fledged production implementation it will give you a good starting point to
complete and customize the solution to your needs. Keep in mind, that it can be improved
by:
- Adding code to ensure the security is working properly
- Adding a DropDown to select the Site Column
Quite a few other modifications could be made to improve it.
Stay tuned next time we will look at how to use it with a Multi-Choice CheckBox.
Happy coding!