3

I have a similar problem as explained in this link: How to change column title for a view, but not modify the list?

But I am not good at work in SharePoint Designer.

How can I open a view page in Designer Mode?

1

1 Answer 1

4

I hope that you want to change a column header like following.

enter image description here

So you can accomplish it by using JsLink. Just override the OnPreRender like following

OnPreRender: function(ctx) {
    var fileName = ctx.ListSchema.Field[1];
    fileName.DisplayName = "File Name";
}

By above code I am changing the first column's header. So my after view is looking now like following

enter image description here

My full code is given below

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {

  function getBaseHtml(ctx) {
    return SPClientTemplates["_defaultTemplates"].Fields.default.all.all[ctx.CurrentFieldSchema.FieldType][ctx.BaseViewID](ctx);
  }

  function init() {

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({

       OnPreRender: function(ctx) { 
       var fileName = ctx.ListSchema.Field[1];
      fileName.DisplayName = "File Name";
       },

      Templates: {

      //     View: function(ctx) { return ""; },
      //     Header: function(ctx) { return ""; },
      //     Body: function(ctx) { return ""; },
      //     Group: function(ctx) { return ""; },
      //     Item: function(ctx) { return ""; },
      //     Fields: {
      //         "<field internal name>": {
      //             View: function(ctx) { return ""; },
      //             EditForm: function(ctx) { return ""; },
      //             DisplayForm: function(ctx) { return ""; },
      //             NewForm: function(ctx) { return ""; }
      //         }
      //     },
      //     Footer: function(ctx) { return ""; }

      },

      // OnPostRender: function(ctx) { },

      ListTemplateType: 101

    });
  }

  RegisterModuleInit(SPClientTemplates.Utility.ReplaceUrlTokens("~siteCollection/Style Library/change-title.js"), init);
  init();

});

I asked you a question in comment but you did not bother to reply. JsLink is only available is SharePoint 2013.

For SharePoint 2010 see here

2

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.