0

I have a page with 2 views of same list. When I use the JSLink to render one of the column (request_id) which is present in both the views, in one view JSLink is working fine, but on the second view it is not working. Below is the code.

<script type="text/javascript">
(function () {
    // Initialize the variable that stores the objects.

    var overrideCtx = {};
    overrideCtx.Templates = {}; 
    overrideCtx.Templates.Fields = {
        'Request_ID': {'View':ChangeStatusIcon}
    };

    // Register the template overrides.
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();

function ChangeStatusIcon(ctx)
{

    var AdminNo= ctx.CurrentItem.Admin_No;
    var Auto = ctx.CurrentItem.Auto_x0023_;
    var RequestDate= ctx.CurrentItem.Request_date;  
    var year = RequestDate.split("-");
    var Current_Year = year[2];
    var urltext="CLM_"+Current_Year+"_"+Auto;
    var url= "/sites/SCL/Lists/Admin%202/Item/editifs.aspx?&ID="+AdminNo+"";
    var coltxt="<a href="+url+" target='_self'>"+urltext+"</a>";
    return coltxt;

}
</script>
  • Make sure that second webpart also has jslink file in the misc section when you edit the wp. – SharePointer Dec 26 '17 at 14:12
  • Can you see any javascript error in the console? Also, remove the script tags and paste your code in the js file and use that js file as JSLink in the webpart settings. – Ahmad Zia Dec 27 '17 at 1:37
0

Try to add condition to limit the view based on ctx properties(ctx.view or others).

Similar thread here.

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.