0

I added a list view to a page. The List contain two columns "Title" and "ReleaseDate". The "Title" is the default column when I create the list. I have not changed the column name.

Here is part of my CSR js code. I call "ReleaseDateViewTemplate" for Title field by purpose. So that I can count how many "Hi" is returned.

overrideCtx.Templates.Fields = {
                "Title": {
            "View": ReleaseDateViewTemplate
        },
        "ReleaseDate": {
            "View": ReleaseDateViewTemplate
        }
    };

function ReleaseDateViewTemplate(ctx) 
{
    alert("hi");
    var date  = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    var monthNames = [ "January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December" ]; 
    var d = new Date(date);
    return "<div class='dateBox'><div class='dayDateBox'>" + d.getDay() + "</div><div class='monthDateBox' >" +  monthNames[d.getMonth()] + "</div></div>";
}

According to my experiment, the ReleaseDateViewTemplate function have not been rendered on the Title field. But it rendered for ReleaseDate field. Any advice to debug it? Thanks.

  • Use the Webtools developer kit from your Web browser (F12) if you want to check for console errors, or to debug your Js. You can put some breakpoints, and spy for variables values at a given time. It's a great way to get unstuck from many issues that could happen. Moreover, by doing this you will be able to get rid of the alert() function and rather use the console.log() or console.error() functions to write your debug purpose messages. – Alex Jun 12 '15 at 7:13
  • I have tried use console.log to track. There is no error at all. The "Title" field is not being overrided at all. I have tried "LinkTitle" as well and nothing happen. Where can I get a list of OOTB field name? – Mark L Jun 25 '15 at 2:54
1

The field name used in CSR code (I think it is not called "Internal field name" as it is referring another value?) for TITLE field are:

  • Title (Title only, no link)
  • LinkTitle (Title with link and with "..." suffix to open a dropdownmenu)
  • LinkTitleNoMenu (Title with link to the document or file but no "..." suffix)

I cannot find any official reference about these field names.

In my code mentioned in question, I replace "Title" to "LinkTitleNoMenu" and everything is working.

  • I tried to change Title's background color. If use 'Title' or 'LinkTitleNoMenu', there is no change. If use 'LinkTitle', the color is changed, but the context is showing 'undefined'. Does anyone know which Title's internal name should be used? – Sofie16 Dec 15 '17 at 19:30
  • @Sofie16 As you mentioned, 'LinkTitle' have effect so it is the correct name. I think your CSR code is not handling the context correctly. – Mark L Dec 18 '17 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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