4

SP2010. I have a list that works fine, and I don't want to modify or rename any of it's columns. Why? I've got plenty of Ajax queries hitting that list, and don't want to break what works.

But, this same list, when rendered in a view for human consumption, has of course, the list column titles, which are not at all what I'd like to show. The list has a few lookup columns, so some column titles are rendered as "myLookupColumn:SomeOtherField". Ugh.

A cursory search here and google reveals there isn't a simple "Display Title" that can be set for list view columns, so I looked at doing an XSL transform. I didn't see how to accomplish this, but I cannot help but think it should be possible.

I'm also up for brute-force changing the column titles by writing a custom jQuery function, but that seems like a rather inelegant solution.

Is there a better way to set customized column titles for a list view?

3 Answers 3

5

The rendering of column headers could be customized using XSLT.

The method described here represents one of the possible ways how it could be accomplished using SharePoint Designer (SPD)

Solution

In SharePoint Designer (SPD) open view page in Designer Mode. Select list header in List View that have to be customized and then click Customize Item as shown on picture below

enter image description here

Switch to Code Mode and find template for column header generated by SPD

<xsl:template name="FieldRef_header.Continent_x003a_Title" ddwrt:dvt_mode="header" match="FieldRef[@Name='Continent_x003a_Title']" mode="header" ddwrt:ghost="show" xmlns:ddwrt2="urn:frontpage:internal">
<!-- your rendering code goes here-->
</xsl:template>

Pay attention to the following template attributes:

mode="header" - correspond to rendering mode for header

match="FieldRef[@Name='Continent_x003a_Title']" - matching attribute for field corresponds to field internal name

Replace generated code for rendering field title:

        <xsl:with-param name="fieldtitle">
          <xsl:value-of select="@DisplayName"/>
        </xsl:with-param>

with the following one:

        <xsl:with-param name="fieldtitle">
              Continent Name 123
        </xsl:with-param>

After these changes the resulting page should like the shown below

enter image description here

An easier solution is to mouse over the column title, a tiny arrow will appear with a link to "Hyperlink options". Click on the link and Confirm with "Yes". Change the "Text to display:" From "javascript:" to the Column Name you wish to show.

Select Hyperlink Options

Change Display Text

New Column Header

3
  • is it also possible to update the values in the rows, like add a formula for calculating something?
    – Gwny
    Commented Jun 19, 2014 at 14:50
  • Is this possible to change the name for multiples column? I have try the same way for more than one column, and I do not get any alias column name, I can only do it for one column, but not for 2 or more. Any suggestion Thanks Luis Acedo
    – user33302
    Commented Sep 10, 2014 at 22:50
  • Is it possible using CSR(Client Side Rendering) in SharePoint 2013 ?
    – Yayati
    Commented Aug 28, 2016 at 10:27
0

This worked for me: Right click the title, select edit formula and replace $fieldtitle with the title you want in quote.

0

In the view page, add the below code in ready function and change the id value i.e., js-listviewthead-WPQ2 to your corresponding id value. You can change column name for more than one column in a view.

$("#js-listviewthead-WPQ2").find('tr>th').each(function(){
            if($(this).find('div').attr("displayname")=="COLUMN DISPLAY NAME1")
            {
                    $(this).find('a:first').text("PREFERED COLUMN NAME1");
        }
if($(this).find('div').attr("displayname")=="COLUMN DISPLAY NAME2")
            {
                    $(this).find('a:first').text("PREFERED COLUMN NAME2");
        }
    });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.