locked
Using Javascript and the Script Editor Web Part on PWA 2013 Task Page RRS feed

  • Question

  • Hi 

    I am in the process of picking up Javascript, and at the moment I am stuck with a little something that I hope someone here in the forum can help me with.

    I have succeed in reading text from text boxes, turning on and off checkboxes on the PWA ribbon (version 2013) with Javascipt embedded in the Script Editor Web Part, but for the life of me, I can not seem to get at the values of the Filter Dropdown (e.g., within the Data group of the PWA "Task" Ribbon).

    First, even with the browser Inspector tool, I am not sure what the id of the object is.  Is it

    • document.getElementById("Ribbon.ContextualTabs.MyWork.Home.Data.FilterDropdown") ?

    or is it...

    • document.getElementById("Ribbon.ContextualTabs.MyWork.Home.Data-Large-2-1") ?

    And then, what is the property or how should go about reading the value of the active filter item (i.e., All incomplete Task, Overdue Tasks, Newly Assigned Tasks, etc.)?  Is it using childNodes[0].nodeValue ?  Or selectedIndex?

    Your help is greatly appreciated!



    \Spiro Theopoulos PMP, MCITP. Montreal, QC (Canada)



    Monday, December 29, 2014 1:21 AM

Answers

  • Hi Spiro,

    Few months even I was trying to achieve same but was getting issue because ribbon buttons can change their size if you resize the browser window ,so the id of the button will be changed respectively, for example from ..-Large to ..-Medium, etc.

    Please check this link for detail discussion and alternative

    http://sharepoint.stackexchange.com/questions/20646/attach-a-javascript-function-to-an-ootb-ribbon-button

    Hope this will help

    Thanks !!!


    Sachin Vashishth MCTS

    Monday, December 29, 2014 2:10 PM

All replies

  • Hi Spiro,

    Few months even I was trying to achieve same but was getting issue because ribbon buttons can change their size if you resize the browser window ,so the id of the button will be changed respectively, for example from ..-Large to ..-Medium, etc.

    Please check this link for detail discussion and alternative

    http://sharepoint.stackexchange.com/questions/20646/attach-a-javascript-function-to-an-ootb-ribbon-button

    Hope this will help

    Thanks !!!


    Sachin Vashishth MCTS

    Monday, December 29, 2014 2:10 PM
  • Hi Sachin,

    Before I read you reply, I had a "Eureka" moment that I was about to write about.  I got my Javascipt to read my the value that was set in the Filterdropdown!  However, you somewhat burst my balloon with the revelation about how re-sizing window changes their size (i.e., Large to Medium, etc)?  It is true, my function does not work when I click the "restore down" icon on the upper right corner of my window, then it works again when I maximize the window.  That sucks : (      Oh, well.  Thanks just the same!

    For what it is worth, here is the script I wrote:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
        <script language="javascript">
            //This function reads the digest using /contextinfo.
            function ShowAlert()
            {
                alert(document.getElementById("Ribbon.ContextualTabs.MyWork.Home.Data-Large-2-1").textContent);
            }
        </script>
    </head>
    <body>
    What filter am I set to?  Click the Button snd I will tell you... <input type="button" value="Button" onclick="ShowAlert()";/>
    </body>
    </html>



    \Spiro Theopoulos PMP, MCITP. Montreal, QC (Canada)


    • Edited by Spiro Theopoulos Monday, December 29, 2014 3:20 PM added some more text
    Monday, December 29, 2014 3:18 PM
  • Hey I am happy that you have your script working and my solution helped you.

    Thanks !!!


    Sachin Vashishth MCTS

    Monday, December 29, 2014 4:00 PM
  • There is one thing that I thought was worth mentioning here:

    For Project "Online", you can add buttons to the Project Web App ribbon, but you can't remove or rename existing product buttons, and you can't create new ribbon tabs. For more information, see How to: Create custom actions to deploy with apps for SharePoint.

    Those who may be interested, can find mention of this in Project Server programmability - http://msdn.microsoft.com/en-us/library/office/ms504195%28v=office.15%29.aspx


    \Spiro Theopoulos PMP, MCITP. Montreal, QC (Canada)

    Tuesday, December 30, 2014 3:25 PM