Created
November 9, 2017 16:25
-
-
Save koohq/5a74c768787e740f8b4adbad5dcd6a9d to your computer and use it in GitHub Desktop.
Changing the display name of field on the SharePoint List view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* sp-fielddisplaynamechanger.js | |
* Provides a function to create a function that changes the display name of field. | |
* The created function is use for JSLink on SharePoint list view pages. | |
* | |
* (c) 2017 koohq. Licensed under CC0. | |
* https://creativecommons.org/publicdomain/zero/1.0/legalcode | |
*/ | |
var SPFieldDisplayNameChanger = (function() { | |
function create(nameMapping) { | |
return function changeFieldDisplayName(renderCtx) { | |
renderCtx.ListSchema.Field.forEach(function(field) { | |
var newName = nameMapping[field.Name]; | |
(typeof newName !== 'undefined') && (field.DisplayName = newName); | |
}); | |
}; | |
} | |
return Object.freeze({ | |
create: create | |
}); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* sp-fielddisplaynamechanger.usage.js | |
* | |
* (c) 2017 koohq. Licensed under CC0. | |
* https://creativecommons.org/publicdomain/zero/1.0/legalcode | |
*/ | |
ExecuteOrDelayUntilScriptLoaded(function() { | |
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({ | |
OnPreRender: SPFieldDisplayNameChanger.create({ | |
'LinkTitle': 'AnotherTitle', | |
'_ModerationStatus': 'Status', | |
'Modified': 'LastWriteTime' | |
}) | |
}); | |
}, 'clienttemplates.js'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment