当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] SharePoint Online:如何从列表中删除标题列?

作者:精品下载站 日期:2024-12-14 15:31:52 浏览:16 分类:玩电脑

SharePoint Online:如何从列表中删除标题列?


要求:从 SharePoint Online 列表中删除“标题”列。

SharePoint Online:如何从列表中删除标题字段?

当您创建新列表时,它默认带有“标题”列。您可以将标题列重命名为与您的列表相关的名称。例如,我创建了一个“指标”列表,并且可以将标题列更改为“指标名称”或类似的内容。但是,有时您可能希望从列表中删除标题字段。这篇文章将解释如何从 SharePoint Online 列表中删除标题列的可用选项。

如何从 SharePoint Online 列表中删除标题列?

删除现代 SharePoint 列表中的标题列非常简单。按着这些次序:

第 1 步:将标题字段设置为可选

  1. 导航至列表设置 >> 单击“列”部分下的“标题”列
  2. 将“要求此列包含信息”设置为“否”并保存更改。

    [玩转系统] SharePoint Online:如何从列表中删除标题列?

第 2 步:隐藏列表表单中的“标题”列

  1. 导航至列表 >> 单击“新建”以打开“新建项目”表单。
  2. 单击右上角的“编辑表单”按钮,然后从菜单中选择“编辑列”。

    [玩转系统] SharePoint Online:如何从列表中删除标题列?

  3. 取消选中“标题”列并点击“保存”。

    [玩转系统] SharePoint Online:如何从列表中删除标题列?

  4. 您还可以通过编辑视图并从视图中取消选中“标题”字段来隐藏列表视图中的标题列。单击标题列,然后单击列设置。然后,“显示/隐藏列”>>取消选中“标题”旁边的复选框,然后单击“应用”。标题列现在将从列表视图中隐藏。

使用内容类型隐藏标题列

在经典经验中,我们必须使用“内容类型”方法从列表中删除“标题”列。

要从列表中删除“标题”列,请执行以下操作:

  1. 导航到要隐藏标题列的列表。单击“设置>>列表设置”。
  2. 单击列表设置页面上的“高级设置”>>为“允许管理内容类型”选择“是”选项,然后单击“确定”。

    [玩转系统] SharePoint Online:如何从列表中删除标题列?

  3. 现在,在列表设置页面中,您将看到“内容类型”链接和“项目”内容类型 >> 单击内容类型下的“项目”链接。
  4. 单击“列”下的“标题”列链接。这将引导您进入一个页面,您可以通过在“列设置”选项下设置“隐藏”来完全隐藏该列,然后单击“确定”。

    [玩转系统] SharePoint Online:如何从列表中删除标题列?

现在返回列表,当您尝试添加/编辑/查看项目时,您将不会看到“标题”列。

您可能需要执行最后一步:从视图中隐藏标题列!在列表设置下,选择带有标题列的视图,然后取消选择标题字段以将其从列表视图中删除。

SharePoint Online:使用 PowerShell 隐藏标题列

标题列是所有 SharePoint Online 列表中都包含的默认列,可用于存储列表项名称等信息。但是,如果您不需要使用标题列,则可以轻松地将其从列表中删除。

我们也可以使用 PowerShell 从列表中隐藏标题列:


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
 
#Config Parameters
$SiteURL= "https://crescent.sharepoint.com/sites/projects"
$ListName="Project Request"
$FieldName = "Title" #Display Name
 
#Setup Credentials to connect
$Cred = Get-Credential
 
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
   
    #Get the web, List and Field objects
    $Web=$Ctx.Web
    $List= $Web.Lists.GetByTitle($ListName)
    $Field = $List.Fields.GetByTitle($FieldName)
 
    #Hide the column from New & Edit forms
    $Field.Required = $False
    $Field.Hidden = $True
    $Field.Update()
    $Ctx.ExecuteQuery()
      
    Write-host -f Green "List Field hidden Successfully!"
}
Catch {
    write-host -f Red "Error hiding List Column: " $_.Exception.Message
}

使用 PnP PowerShell,隐藏列表中的标题字段要简单得多:


#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/pmo"
$ListName = "Metrics"
$FieldName = "Title"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Hide the field
Set-PnPField -List $ListName -Identity $FieldName -Values @{Required=$False;Hidden=$True}

如果您注意到了,我们没有在上述 PowerShell 方法中启用列表上的内容类型并将字段设置为“隐藏”。如果您想遵循这种方法,请执行以下操作:


#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/pmo"
$ListName = "Metrics"
$FieldName = "Title"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
$Ctx = Get-PnPContext

#Enable Content Type
Set-PnPList -Identity $ListName -EnableContentTypes $True

#Get the default content type
$ContentType = (Get-PnPContentType -List $ListName)[0]
 
#Get the Field from Content Type
$ContentTypeField = $ContentType.Fields.GetByInternalNameOrTitle($FieldName)
$Ctx.Load($ContentTypeField)
$Ctx.ExecuteQuery()
 
#Set Hidden Property of the field
$ContentType.FieldLinks.GetById($ContentTypeField.Id).Hidden = $True
$ContentType.Update($False) #Update Children 
$Ctx.ExecuteQuery()

从 SharePoint Online 列表中删除标题列是一个简单的过程,只需要几个步骤,如上所示。借助本指南,您应该能够快速从 SharePoint Online 中的任何列表中删除标题列。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯