SharePoint 2013自定义自定义字段筛选器

时间:2016-09-02 09:01:07

标签: filter sharepoint-2013 custom-field-type

我在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>

我的CrossSiteLookupField类继承自SPFieldText。方法'public override string GetValidatedString(object value)'返回例如'4; #Test'(就像一个SPFieldLookup)。现在过滤器显示'4; #Test',但我希望只显示'Test'。 第二个问题是:如果我有一个用'分隔的多值; ',我想有两个过滤行。

该功能应该等于Lookup和LookupMulti。

我该怎么做?

THX

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。 您可以在C:\ Program Files \ Common Files \ microsoft shared \ Web Server Extensions \ 15 \ TEMPLATE \ LAYOUTS中更改Filter.aspx页面。 此页面创建选择过滤器的选项。 添加javascript可以更改这些选项。 使用此代码:

<Script>
$ (Document) .ready (function ()
{
var presentText;
$ ( "Select> options"). Each (function () {
Originaltext var = $ (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;
}
});
});
</ Script>

编辑过滤器的声音: original option 至 : modified option