locked
Change column display name RRS feed

  • Question

  • Hi,

    How can one change the display name of a column.

    For example I have columns C_ProjectID which when display in view should appear "Project ID". I tried to play with FieldRef but somehow it doesn't reflect the change on page.

    What I am missing here? Below is the schema from Sharepoint designer.

    Thanks in advance.

    Regards,

    Abdul

     


                    <ViewFields>
                        <FieldRef Name="TISImpact_x0020__x0028_Yes_x0020" DisplayName="Impact (Y/N)"/>
                        <FieldRef Name="C_Title" DisplayName="Title"/>
                        <FieldRef Name="C_ProjectID" DisplayName="Project ID"/>
                        <FieldRef Name="TBP"/>
                    </ViewFields>


    Monday, November 28, 2011 9:29 AM

Answers

  • Hi,

    To change the column name, you can simply select the field name from the ListSettings page and change its title /column name to the desired name. Note:the internal name of the column will still remain the same.

    Secondly, you can also do this progrmatically too :

     using (SPSite site = new SPSite("http://site"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        SPList sampleList = web.Lists["ListName"];
    
                        // Imp Step
                        SPField title = sampleList.Fields.GetFieldByInternalName("C_ProjectID");
                        title.Title = "Custom";
                        title.Update(true);
                        sampleList.Update();
    
                        web.AllowUnsafeUpdates = false;
                    }
                }
    

    You can change the display name via Sharepoint Designer bu clicking on the list -> list settings -> click on "Edit list columns" under cutomizations > select the column and right click and select rename.

     

    Hope this helps

    Regards,


    Priyanka
    Monday, November 28, 2011 10:38 AM

All replies

  • Hi Abdul,

    When we create a new column in SharePoint List, it set two properties in FieldRef:

    1. Column Internal name which is set once on first time and can't be changed later.

    2. DisplayName which you can modify any time by going to List settings and click on column to edit. On change of DisplayName, Internal name will not change as it is reference by SharePoint internally.

    How you are creating view? Can you please elaborate your problem?

     

     


    Regards,
    Rajan
    My Blog: http://rajangarg.wordpress.com/
    Monday, November 28, 2011 10:30 AM
  • Hi,

    To change the column name, you can simply select the field name from the ListSettings page and change its title /column name to the desired name. Note:the internal name of the column will still remain the same.

    Secondly, you can also do this progrmatically too :

     using (SPSite site = new SPSite("http://site"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        SPList sampleList = web.Lists["ListName"];
    
                        // Imp Step
                        SPField title = sampleList.Fields.GetFieldByInternalName("C_ProjectID");
                        title.Title = "Custom";
                        title.Update(true);
                        sampleList.Update();
    
                        web.AllowUnsafeUpdates = false;
                    }
                }
    

    You can change the display name via Sharepoint Designer bu clicking on the list -> list settings -> click on "Edit list columns" under cutomizations > select the column and right click and select rename.

     

    Hope this helps

    Regards,


    Priyanka
    Monday, November 28, 2011 10:38 AM
  • Hi,

    Sorry that I didnt explain my problem in detail.

    I am creating the view by using sharepoint ribbon. Thing is that I already have two columns lets say, Project ID and C_ProjectID (which is a calculated column type that contains project id). I would like to use same column header for both "ProjectID" and "C_ProjectID". Renaming in this case is not possible or?

    Is there a way to change the header without using code?

    Below you can see an example of what I am trying to say.

    Monday, November 28, 2011 3:11 PM
  • Hi,

    Have you tried Rajan's suggestion? You can modify the column, and change the title directly. It won't change the internal name, but will change the display name.

    Thanks,
    Jinchun Chen


    Jinchun Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff AT microsoft.com(Please replace AT with @)
    Wednesday, November 30, 2011 8:20 AM
  • Just go to list settings--> in Columns section select your column, rename it & click on OK
    Wednesday, November 30, 2011 9:18 AM
  • Renaming isn't possible. Consider the following. I have two columns,

    Title

    C_Title

    Now when I try to rename the column C_Title to "Title", sharepoint tells me this isn't possible as Title already exists!

    Wednesday, November 30, 2011 1:26 PM
  • Hi, I'm a bit new to SharePoint development and wanted to ask if you could explain how to apply your above proposed c# solution to this list.  I've been doing some front-end js developing, but can't seem to grasp an easy way to apply a solution like you have above to an existing list.  Would you do this through deploying a solution through Visual Studio or is there an easier way to apply this code?

    Thank you!!

    Wednesday, April 23, 2014 3:11 PM