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>
2
  • Make sure that second webpart also has jslink file in the misc section when you edit the wp. Commented Dec 26, 2017 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
    Commented Dec 27, 2017 at 1:37

1 Answer 1

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 and acknowledge you have read our privacy policy.

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