简体   繁体   中英

How to hide “Title” standard column in custom list using visual studio

I'm working on custom lists of sharepoint 2013.

I created many lists in each one I want to hide the standard column "Title" from visual studio . I know how to deal with this in SharePoint Site ( by making this field hidden in the column list ) , but every time I make changes in my list ( in visual studio) and deploy the project , the Title field becomes required.

Is there a way to force the "Title" standard column to "hidden" in visual studio ?

can anyone help me Please?

You can use this -

using (ClientContext ctx = new ClientContext("http://siteUrl"))
    {
        Field field = ctx.Web.Lists.GetByTitle("myListName").Fields.GetByTitle("Title");
        field.Hidden = true;
        field.Required = false;
        field.Update();
        ctx.ExecuteQuery();
    }

This happens when your list inherits from the default parent content type, such as "item".

So I recommand to : 1 - create your custom content type, disable the inheritance from the parent content type 2 - create your custom list and delete the default content type and replace it by the custom one.

Hope this can help.

You can follow the Solution Hemi has provided bu there is one another way you can think a workaround for this. You can delete that column from the view itself.

Please have a look at this code.

 SPView view = list.DefaultView; if(view.ViewFields.Exists("LinkTitle")) { view.ViewFields.Delete("LinkTitle"); view.Update(); } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM