0

I need to overwrite a multiline sharepoint field by a tooltip but it's not wotking.

    (function () {

    var SubjectFiledContext = {};
    SubjectFiledContext.Templates = {};

    SubjectFiledContext.Templates.Fields = {
        // Apply the new rendering for Body field on list view

        "subject": { "View": SubjectFiledTemplate}



    };


    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(SubjectFiledContext);

})();

function SubjectFiledTemplate(ctx) {

       var subjectValue =ctx.CurrentItem.subject;

        //This regex expression use to delete html tags from the Body field
        var regex = "/(<([^>]+)>)/ig";



        subjectValue = subjectValue.replace(regex, "");
subjectValue = subjectValue.replace(/<br>/g, "&#013;");



        var newSubjectValue = subjectValue;


        if (subjectValue && subjectValue.length >= 20)
        {
            newSubjectValue = subjectValue.substring(0, 20) + " ...";
        }


        return "<span title='" + subjectValue + "'>" + newSubjectValue+ "</span>";
    }

I tried to test it simply :

    (function () {

    var SubjectFiledContext = {};
    SubjectFiledContext.Templates = {};

    SubjectFiledContext.Templates.Fields = {
        // Apply the new rendering for Body field on list view

        "subject": { "View": "test"}



    };


    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(SubjectFiledContext);

})();

Its not working again! I activated/deactivate the MDS feature and always the same thing, not working!

To call the jslink script on the webpart, I've linked to: ~sitecollection/_catalogs/masterpage/subject_template.js

  • Use the Chrome browser and the Cisar Chrome Extension to create/edit CSR files – Danny '365CSI' Engelman May 31 '16 at 15:15
  • I installed the Cisar Chrome Extension and I published the jslink script but it's not working ! – A.R Jun 1 '16 at 17:39
  • If you add a JSLink referencing a file with only console.log('I executed'); it should work, then take it from there. "View":"test" will never work as it expects a Function to return an HTML string – Danny '365CSI' Engelman Jun 1 '16 at 18:51
1

Thank you all !

it's fixed it using the Cisar Chrome Extension and the problem was related to Field internal Name

| improve this answer | |
0

Try editing the first word in the path from "~sitecollection" to "~site"

~site/_catalogs/masterpage/subject_template.js

| improve this answer | |

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.