0
votes

I've created a custom field in SharePoint 2013.

<FieldTypes>
  <FieldType>
    <Field Name="TypeName">CrossSiteLookupField</Field>
    <Field Name="ParentType">Text</Field>
    <Field Name="TypeDisplayName">Cross-Site Lookup Field</Field>
    <Field Name="TypeShortDescription"> Cross-Site Lookup Field </Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="ShowOnColumnTemplateCreate">TRUE</Field>
    <Field Name="ShowOnListCreate">TRUE</Field>
    <Field Name="ShowOnDocumentLibraryCreate">TRUE</Field>
    <Field Name="ShowOnSurveyCreate">FALSE</Field>
    <Field Name="ShowInFileDlg">FALSE</Field>
    <Field Name="Sortable">TRUE</Field>
    <Field Name="Filterable">TRUE</Field>
    <Field Name="AllowBaseTypeRendering">FALSE</Field>
    <Field Name="CAMLRendering">TRUE</Field>
    <Field Name="AllowGridEditing">FALSE</Field>

    <Field Name="FieldTypeClass">CrossSiteLookupField.CrossSiteLookupField,$SharePoint.Project.AssemblyFullName$</Field>
    <Field Name="FieldEditorUserControl">/_controltemplates/15/CrossSiteLookupFieldAdminTemplate.ascx</Field>

  </FieldType>
</FieldTypes>

My CrossSiteLookupField class inherits from SPFieldText. The method 'public override string GetValidatedString(object value)' returns e.g. '4;#Test' (like a SPFieldLookup). Now the filter shows '4;#Test' but I would like the have 'Test' displayed only. The second question is: If I have a multivalue separated with '; ', I would like to have two filter rows.

The functionality should be equal to Lookup and LookupMulti.

How can I do this?

Thx

1

1 Answers

0
votes

I had the same problem. You can change the Filter.aspx page in C: \ Program Files \ Common Files \ microsoft shared \ Web Server Extensions \ 15 \ TEMPLATE \ LAYOUTS. This page creates the option of select the filter. Adding the javascript you can change these options. With this code:

$(document).ready(function ()
{
    var presentText;

    $("select > options").each(function ()
    {
        var originalText = $(this).text();
        if (originalText.indexOf("#") >= 0)
        {
            var textElement = originaltext;
            if (textElement == presentText)
                $(this).remove();
            else {
                var newText = originalText.substring(2, originalText.indexOf("#", 2));
                if (newText == "")
                    newText = "Empty";

                if (originalText.indexOf("true") >= 0)
                    newText += "(Validated)";
                else
                    newText += "(not valid)";

                $(this).text(newText);
            }
            presentText = textElement;
        }
    });
});

Edit the voices of the filters: original option to : modified option