This is not documented anywhere (I found this by trial and error and some help from .NET Reflector - http://www.red-gate.com/products/dotnet-development/reflector/) - but you can actually have both the JSLink render your field in your SharePoint list view and take full advantage of server rendering of controls (e.g. using Telerik AutoComplete for Token Selection) at the same time.
You can do this by overriding the JSLink property in your Field class (inheriting from SPField) as below so that it renders your full controls for Display/Edit and renders your JSLink for viewing in a list:
public override string JSLink { get { if (SPContext.Current != null && SPContext.Current.FormContext.FormMode == SPControlMode.Invalid) return "../_layouts/15/MyProjectName/CustomFieldControl.js"; else { return string.Empty; } } set { base.JSLink = value; } }As above, this looks at the current SPContext to determine whether it is currently rendering in the list view (and renders the JSLink property) - otherwise, it just uses the default server control rendering behaviour.
DDK
No comments:
Post a Comment