We can change column name from JavaScript, it will
not affect your existing functionality or custom code and also no need to change
column name from SharePoint Designer as it is a troublesome task.
Follow this steps….
1. Get column Id using Developer tool.
2. Add following JavaScript in Content Editor web part on the list view.
<script type="text/javascript">
//This script is developed by Mohammad Yusuf Hussain # http://mohammadyusufhussain-sharepoint.blogspot.in/
_spBodyOnLoadFunctionNames.push("ChangeColumnName"); // Call ChangeColumnName function on PageLoad
function ChangeColumnName()
{
RenameColumn('diidSortAuthor', 'Author'); //Provide Column ID and New Column name
}
function RenameColumn(colID, NewHeader) {
try {
document.getElementById(colID).innerHTML = NewHeader; //Change Header Name
document.getElementById(colID).title = "Sort by " + NewHeader; // Change Tooltip value
}
catch (err) {
alert('Invalid Column ID:' + colID);
}
}
</script>
{
RenameColumn('diidSortAuthor', 'Author'); //Provide Column ID and New Column name
}
function RenameColumn(colID, NewHeader) {
try {
document.getElementById(colID).innerHTML = NewHeader; //Change Header Name
document.getElementById(colID).title = "Sort by " + NewHeader; // Change Tooltip value
}
catch (err) {
alert('Invalid Column ID:' + colID);
}
}
</script>
Old Column Name:
New Column Name:
Thanks a lot... Nice post... it helped me a lot..
ReplyDeletegreat!!
ReplyDeleteThanks, that was very helpful.
ReplyDeleteI have multiple list view web parts on my page and it only changes the first one. How can I make this code change all list views with the name "ID"?
ReplyDelete