none
How to remove displayform link from items in a calendar view? SPO

    Question

  • Hello,

    I made a calendar view from a list in SharePoint Online, works perfectly displaying birthday events... But, it shows users data that can't be public... The calendar gives the link to a display form for every item displayed in the calendar, and of course, the displayform shows personal data of the user and also there is the "edit element" option on the ribbon which is dangerous.

    Is there anyway to convert all those links in to a only text in the calendar?

    For example, this is the calendar:

    Then, when you click on someone, it links you to the displayform that i don't want... I need to remove those links, and keep only the text...

    i hope i get help, thanks.

    Greetings,


    Guardar
    • Edited by Luis Colón Sunday, April 16, 2017 4:09 PM SharePoint Online
    Wednesday, April 12, 2017 2:48 AM

Answers

  • Hi Luis Colón,

    Try adding the following scripts to the page:

    <script src="../../SiteAssets/jquery-1.4.2.min.js" type="text/javascript"></script>
    
    <script>
    
    $(document).ready(function () {
    
    $(".ms-acal-rootdiv").bind("click dblclick", function () {
    
    return false;
    
    });
    
     
    
    setInterval(function () {
    
    $(".ms-acal-item [bricked!='1']").each(function () {
    
    $(this).attr("bricked", "1").bind("click dblclick", function () {
    
    return false;
    
    });
    
    });
    
    // Single day events
    
    $(".ms-acal-sdiv a").each(function () {
    
    var text = $(this).text();
    
    $(this).before(text);
    
    $(this).remove();
    
     
    
    });
    
    // Events spanning multiple days
    
    $(".ms-acal-mdiv a").each(function () {
    
    var text = $(this).text();
    
    $(this).before(text);
    
    $(this).remove();
    
     
    
    });
    
    // Events for day view
    
    $(".ms-acal-ddiv a").each(function () {
    
    var text = $(this).text();
    
    $(this).before(text);
    
    $(this).remove();
    
     
    
    });
    
    $("td[evtid=day]").removeAttr("evtid");
    
    $("th[evtid=week]").removeAttr("evtid");
    
    }, 500);
    
     
    
    /* Disable links for Calendar View End */
    
     
    
    });
    
    </script>


    Best Regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Luis Colón Monday, April 17, 2017 2:03 AM
    Thursday, April 13, 2017 8:48 AM
    Moderator
  • Hi Luis Colón,

    Please check the console to see if there are some errors.

    Make sure you have included the jQuery JavaScript Library. Download the jQuery API and upload the .js file into the SiteAssets Document Library.

    Modify the following script a bit for applying to your .js file.

    <script type="text/javascript" src="../../SiteAssets/jquery-1.4.2.min.js"></script>


    Best Regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Luis Colón Monday, April 17, 2017 2:03 AM
    Monday, April 17, 2017 1:23 AM
    Moderator

All replies

  • With JSLink functionality it's not possible to disable href tag for particular item, in this case you can utilize below mentioned script to disable href tag, so that user can't able to redirect to display page: for this you need to add JQuery reference:

        $(".ms-acal-rootdiv").find('div[class^="ms-acal-"]').find('a').each(function() { 
            $(this).attr('onclick','');
            $(this).attr("href","javascript:void();");
        });


    Thanks, Amit Kumar, LinkedIn Profile ** My Blog
    Please click "Mark As Answer" if this post solves your problem or "Vote As Helpful" if it was useful

    Wednesday, April 12, 2017 7:23 AM
  • Hi Luis Colón,

    Try adding the following scripts to the page:

    <script src="../../SiteAssets/jquery-1.4.2.min.js" type="text/javascript"></script>
    
    <script>
    
    $(document).ready(function () {
    
    $(".ms-acal-rootdiv").bind("click dblclick", function () {
    
    return false;
    
    });
    
     
    
    setInterval(function () {
    
    $(".ms-acal-item [bricked!='1']").each(function () {
    
    $(this).attr("bricked", "1").bind("click dblclick", function () {
    
    return false;
    
    });
    
    });
    
    // Single day events
    
    $(".ms-acal-sdiv a").each(function () {
    
    var text = $(this).text();
    
    $(this).before(text);
    
    $(this).remove();
    
     
    
    });
    
    // Events spanning multiple days
    
    $(".ms-acal-mdiv a").each(function () {
    
    var text = $(this).text();
    
    $(this).before(text);
    
    $(this).remove();
    
     
    
    });
    
    // Events for day view
    
    $(".ms-acal-ddiv a").each(function () {
    
    var text = $(this).text();
    
    $(this).before(text);
    
    $(this).remove();
    
     
    
    });
    
    $("td[evtid=day]").removeAttr("evtid");
    
    $("th[evtid=week]").removeAttr("evtid");
    
    }, 500);
    
     
    
    /* Disable links for Calendar View End */
    
     
    
    });
    
    </script>


    Best Regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Luis Colón Monday, April 17, 2017 2:03 AM
    Thursday, April 13, 2017 8:48 AM
    Moderator
  • Hello Amit,

    I tried adding your script to a command secuence editor web part, but didn't work. I'm not sure if im doing it well...

    I tried clicking on users name and im still getting to the display form.

    Greetings,

    • Marked as answer by Luis Colón Monday, April 17, 2017 2:03 AM
    • Unmarked as answer by Luis Colón Monday, April 17, 2017 2:03 AM
    Saturday, April 15, 2017 11:47 PM
  • Hello Linda,

    I tried adding your script too in a command secuence editor web part, but didn't work. I'm not sure if im doing it well... Also tried with a content editor web part, but still same...

    I tested clicking on users name and im still getting to the display form.

    Greetings,

    Saturday, April 15, 2017 11:51 PM
  • Hi Luis Colón,

    Please check the console to see if there are some errors.

    Make sure you have included the jQuery JavaScript Library. Download the jQuery API and upload the .js file into the SiteAssets Document Library.

    Modify the following script a bit for applying to your .js file.

    <script type="text/javascript" src="../../SiteAssets/jquery-1.4.2.min.js"></script>


    Best Regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Luis Colón Monday, April 17, 2017 2:03 AM
    Monday, April 17, 2017 1:23 AM
    Moderator
  • Oh, great. It worked!

    I was missing the Jquery API in the SiteAssets library.

    Now all the links in the day, week and month calendar views are deactivated.

    Thanks so much!

    Monday, April 17, 2017 2:03 AM