1

Can anyone help me with changing the name of a column in list view with JavaScript/jQuery?

  • Kindly check here...sharepoint.stackexchange.com/questions/50004/… – Hardik Aug 10 '16 at 10:59
  • I don't have access to SPD. Therefore, looking for a JS based solution. – Korak Aug 10 '16 at 11:02
  • Did you tried below solution to change the display name for column? – Hardik Aug 10 '16 at 12:44
  • 2
    Can't you simply go into the list settings and change the column name? This will then get reflected in any views the field is used. – Eric Alexander Aug 11 '16 at 12:42
1

The simplest solution here to me seems to be to go into your list settings and simply changing the name of your field. Click on the hyperlink for the column and change it's name. This will then replicate to any views that leverage this column and show the new name.

But it isn't clear what you are really trying to get at.

| improve this answer | |
0

Since SharePoint Designer is not an option ,you can add javascript on the view to change the column heading

  1. Get the id for the column heading link .You can use the developer tool by pressing F12 in IE .
  2. Use the arrow to select the column heading on the view ,the html for the heading will show up .
  3. Add a Content Editor web part on the page .Then click on Click here to add content .Choose HTML in the ribbon and click Edit HTML source.
  4. Add these codes inside the HTML source :

JS Code

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//alert('b');
$('#diidSortLinkTitle').text('aaa');
})
</script>

Note:

In above code, diidSortLinkTitle is sample ID for the control. You need to use the ID for column header which you want to change.

E.G.

Below is my code which i got using F12 (developer tool) for Title column.

<a column"="" sort="" to="" click="" sortingfields="View={ce1e4c67-bbc1-4248-9aab-99a799debe86}&amp;SortField=LinkTitle&amp;SortDir=Asc Title=" href="javascript: " onclick="javascript: var pointerType = this.getAttribute('pointerType'); if (pointerType != null &amp;&amp; typeof MSPointerEvent != 'undefined' &amp;&amp; Number(pointerType) != MSPointerEvent.MSPOINTER_TYPE_MOUSE) { ListHeaderTouchHandler(event); return false; } return OnClickFilter(this, event);" onfocus="OnFocusFilter(this)" id="diidSort0LinkTitle" class="ms-headerSortTitleLink">Title</a>

I used ID mentioned in above tag (diidSort0LinkTitle) in my given script & it is working fine.

| improve this answer | |
  • I could not find any id for the column from list view. Here's my HTML - <div class="ms-vh-div" name="External_x0020_Com" SortFields="View={9edbe4e6-7d59-4ccf-b4fa-47742c00fe22}&SortField=External_x0020_Com&SortDir=Asc" ResultType="" FieldType="Note" DisplayName="External Com" CTXNum="11395" FilterDisableMessage="" Filterable="FALSE" FilterDisable="" SortDisable="" Sortable="FALSE"> – Korak Aug 10 '16 at 13:04
  • There must be a unique thing for that control (header of the list - label) in your code. by that you can achieve that. Try to apply CSS in IE DOM explorer & if it is working that use the same CLASS or ID. – Hardik Aug 10 '16 at 13:15
  • Have you achieved it or do you need help in it? – Hardik Aug 11 '16 at 12:24
  • I had tried the same to change the column name from title to title1 & it is working fine. I have pasted my code for title column name in my answer as well. – Hardik Aug 11 '16 at 12:27

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