0

I'm creating a custom field type for Sharepoint using the JSLink method. This field will be used in New List Item / Edit List Item forms.

What I want to do is to allow a user to set a custom property in the list column settings, and then access this property from within the custom field.

Here's what I tried:

1) Using this in the XML file for the field type - this method works for server-side create

 <PropertySchema>
      <Fields>
        <Field Name="MyCustomProperty" DisplayName="This is my custom property" Type="Text" Hidden="False" />
      </Fields>
 </PropertySchema>

2) Using this in the code that initializes the control:

    public MyCustomFieldType(SPFieldCollection fields, string fieldName) :
        base(fields, fieldName)
    {
        this.RichText = true;
        this.RichTextMode = SPRichTextMode.Compatible;
        this.RestrictedMode = false;
        this.UnlimitedLengthInDocumentLibrary = true;
        this.SetCustomProperty("TestProperty", "test1");
        this.ThisIsACustomProperty = "test3";
    }

It seems there is no way I can access those fields from the javascript. Any ideas?

  • 1
    Short: JSLink is for only changing how a field is rendered, not how it functions "behind the scenes" – Robert Lindgren Jul 19 '16 at 6:31
0

refer msdn

In short, override this method in your C# code, then your custom property will appear in the form context / field schema in javascript.

public override Dictionary<string, object> GetJsonClientFormFieldSchema(Microsoft.SharePoint.WebControls.SPControlMode mode)
        {
            Dictionary<string, object> schema = base.GetJsonClientFormFieldSchema(mode);
            schema.Add("my_displaytemplate", this.DisplayTemplate ?? string.Empty);
            return schema; 
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy