【问题标题】:Hide a SharePoint list column based on the value of another column根据另一列的值隐藏 SharePoint 列表列
【发布时间】:2019-11-06 13:13:30
【问题描述】:

我在 SharePoint 中为列表创建了列。一些列是选择列。当我创建一个新项目时,所有列都可见以填充有关新项目的数据。

我需要能够根据在其中一个选项列中选择的选项显示/隐藏某些字段。我已经对此进行了一些研究,但似乎只能使用代码来做到这一点。不幸的是,我无法访问我们的 SharePoint 网站的代码或 SharePoint Designer 功能,所以我想知道是否有办法使用计算列中的公式来做到这一点?

谢谢。

西里尔

【问题讨论】:

    标签: sharepoint


    【解决方案1】:

    要将 JavaScript 代码添加到新表单页面,我们不需要使用 SharePoint 设计器。我们可以在 UI 中编辑页面并将脚本编辑器 Web 部件添加到页面中,然后添加 JavaScript 代码来实现它。示例代码。

    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $('nobr:contains("Field1")').closest('tr').hide();  
            //Show/hide columns based on Drop Down Selection 
            $("select[title='ChoiceField']").change(function() {
            if ($(this).val() != "Other"){
                $('nobr:contains("Field1")').closest('tr').hide();
            }else{
                $('nobr:contains("Field1")').closest('tr').show();
            }
        });
    });
    </script>
    

    参考:Show / Hide fields based on choice field selection using JQuery in SharePoint

    如果您不想使用代码,请使用 InfoPath 来实现。 检查这个:How to Hide a field on the List form based on another field

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-04
      • 1970-01-01
      相关资源
      最近更新 更多