Javascript to Expand/Collapse all grouped list items(2010 method no longer working)

I have the below little piece of javascript that used to work in 2010(with plus.gif/minus.gif)
<html>
<head>
<script language="Javascript" type="text/Javascript">
function collapseGroups() { 
$("img[src*='spcommon.png']:visible").parent().click(); 
function expandGroups() { 
$("img[src*='spcommon.png']:visible").parent().click(); 
</script>
</head>
<body>
<input type="button" id="btnExpand" onclick="expandGroups()" value="Expand All">
<input type="button" id="btnExpand" onclick="collapseGroups()" value="Collapse All">
</body>
</html>
This however does not work and results in a lot of "clicks" occuring on the site, wherever the spcommon.png is present(which is a lot)
Has anyone hit this issue before?
Regards
Pieter
PS. Works on 2010 with plus/minus.gif.
Regards, Pieter
MCPD | MCITP
My Blog
Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

Hi,
In SharePoint 2013, we can add the following code into a Content Editor Web Part to achieve it.
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script language="Javascript" type="text/Javascript">
function collapseGroups() {
$("img[id^='img_']").click();
function expandGroups() {
$("img[id^='img_']").click();
</script>
<input id="btnExpand1" onclick="expandGroups()" type="button" value="Expand All" />
<input id="btnExpand2" onclick="collapseGroups()" type="button" value="Collapse All" />
Best Regards
Dennis Guo
TechNet Community Support

Similar Messages

  • Expand/Collapse all the Bookmarks in a PDF file

    Hi,
    This is my first message on the board :-)
    I work with very large PDF files (i.e 2000 pages, 700 bookmarks on 5 or 6 levels!) and I'm looking for a script (Acrobat 9 Pro) allowing to expand/collapse all the bookmarks in a PDF file.
    Thanks in advance for your valuable help,
    Cheers
    Antonella

    The Acrobat Javascript Scripting reference (http://partners.adobe.com/public/developer/en/acrobat/sdk/AcroJS.pdf) describes how to use scripting to access bookmarks and how to open and close them, which is what you're looking for.
    I suggest you read the reference and make a function that will do the job for you.
    That's the way I would do it.
    I don't think you can access the keyboard shortcuts "/" and "Shift + *" via scripting.
    Torben.

  • Expand/Collapse All Version Sets

    PSE 10, Is there a simple way to open all the Version Sets with one set of keystrokes, and having them stay open. I have a lot of version sets built up over time, and I would prefer not having to open each one individually. When I tried doing that on a small batch, as soon as I  changed to a different batch of pics, all of the Sets I had opened, promptly closed. The View > Expand/Collapse All Stacks does not work on the Version Sets.

    Hi Surya
    Create a new HTML region at the top of your page, using No Template and use this as the Source:
    &lt;script type="text/javascript"&gt;
    function showHideAll(displaystyle)
    var hideIMG = "/i/htmldb/builder/rollup_plus_dgray.gif";
    var showIMG = "/i/htmldb/builder/rollup_minus_dgray.gif";
    var k;
    var r = document.getElementsByTagName("DIV");
    if (r)
       for (k = 0; k &lt; r.length; k++)
         if (r[k].className == 't12Hide')
           r[k].style.display = displaystyle;
    var i = document.getElementsByTagName("IMG");
    if ( i )
      for (k = 0; k &lt; i.length; k++)
        if (i[k].id.substr(0, 5) == 'shIMG')
          i[k].src = (displaystyle == 'block') ? showIMG : hideIMG;
    &lt;/script&gt;
    &lt;a href="javascript:showHideAll('block');"&gt;Show All&lt;/a&gt;
    &lt;a href="javascript:showHideAll('none');"&gt;Hide All&lt;/a&gt;The image names and className (t12Hide) are based on my test page - change these as appropriate for your own page (you may need to do a View Source on the page to check these values).
    Andy

  • Decision Report: Toggling Expand / Collapse All (v10.2)

    Hi everyone,
    We're wondering if anyone can share an approach for enabling users to "expand/collapse all" (all nodes) in a decision report dynamically - i.e. using a button or toggle, rather than a global configuration or preference setting. For example, we would like to initially display a collapsed report (to show the high-level conclusions), and then enable the client to fully expand the report for printing.
    Importantly, we would like to be able to do this in version *10.2*.
    Thanks,
    - Patrick

    Granting my JavaScript is a bit rusty, I'm wondering if anyone else has encountered the following challenge when changing the global configuration settings for decision report (expanded/collapsed):
    Issue: The plus signs ( + ) at the nodes appear as minus signs ( - ), and vice versa. In other words, after our modifications, the user needs to click on a minus sign to expand a node.
    Our approach was simply to do a CTRL-F and replace "expanded" with "collapsed", so it's not surprising that there were unintended side effects.

  • Expand/collapse all regions

    I have 5 show/hide regions on a page. is it possible to Expand/collapse all regions by clicking a "Show/Hide All" link or a button. any ideas are appreciated.
    thanks,
    Surya

    Hi Surya
    Create a new HTML region at the top of your page, using No Template and use this as the Source:
    &lt;script type="text/javascript"&gt;
    function showHideAll(displaystyle)
    var hideIMG = "/i/htmldb/builder/rollup_plus_dgray.gif";
    var showIMG = "/i/htmldb/builder/rollup_minus_dgray.gif";
    var k;
    var r = document.getElementsByTagName("DIV");
    if (r)
       for (k = 0; k &lt; r.length; k++)
         if (r[k].className == 't12Hide')
           r[k].style.display = displaystyle;
    var i = document.getElementsByTagName("IMG");
    if ( i )
      for (k = 0; k &lt; i.length; k++)
        if (i[k].id.substr(0, 5) == 'shIMG')
          i[k].src = (displaystyle == 'block') ? showIMG : hideIMG;
    &lt;/script&gt;
    &lt;a href="javascript:showHideAll('block');"&gt;Show All&lt;/a&gt;
    &lt;a href="javascript:showHideAll('none');"&gt;Hide All&lt;/a&gt;The image names and className (t12Hide) are based on my test page - change these as appropriate for your own page (you may need to do a View Source on the page to check these values).
    Andy

  • Collapse all groups in a CFGrid by default

    Is there a setting that would collapse all groups in a CFGrid by default? I have a lot of data in each group and it would make viewing the data much easier. Thanks!

    textAreaObj.requestFocus() doesn't do it?
    If that doesn't do it, then try textAreaObj.setSelectionStart(0).
    You may have to force a repaint(), possibly, as well.

  • DHTML Tree Expand-Collapse ALL buttons

    Hi
    I am using at DHTML Tree (in APEX 3.0.1) as a menu. I am wondering if it is possible to add buttons (or link) to the region which a user can click to expand all or collapse all nodes in the tree.
    I don not want the tree to be expanded or collapsed all the time (as when using the Tree List template)
    Thanks

    Anyone?

  • Expand/Collapse all in OneNote 2013?

    Once I've created a hierarchy in OneNote, is there any way I can collapse all or expand all in a single click, or am I destined to have to click more than 100 [+]  when I want to see everything? Thanks.

    Hi,
    Do you mean you want to expand all collapsed outlines by single click? If so, we can use Alt + Shift + 0 to expand all levels in OneNote. Some related keyboard shortcut key are listed below:
    Show through Level 1.
        ALT+SHIFT+1
    Expand to Level 2.
        ALT+SHIFT+2
    Expand to Level 3.
        ALT+SHIFT+3
    Expand to Level 4.
        ALT+SHIFT+4
    Expand to Level 5.
        ALT+SHIFT+5
    Expand to Level 6.
        ALT+SHIFT+6
    Expand to Level 7.
        ALT+SHIFT+7
    Expand to Level 8.
        ALT+SHIFT+8
    Expand to Level 9.
        ALT+SHIFT+9
    Expand all levels.
        ALT+SHIFT+0
    Increase indent by one level.
        TAB
    Decrease indent by one level.
        SHIFT+TAB
    Expand a collapsed outline.
        ALT+SHIFT+PLUS SIGN
    Collapse an expanded outline.
        ALT+SHIFT+MINUS SIGN
    Hope this helps.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • DTreeTable Expand/Collapse All

    I was wondering if anyone had any experience with the DTreeTable plugin found here: http://apex-plugin.com/oracle-apex-plugins/region-plugin/dtreetable_68.html
    If so, has anyone implemented an expand all or collapse all button with it?
    An example of the onclick for each node is dttToggleNode('2597807651112537', 1) - I could loop through these and click them all but is there a nicer way?
    Thanks.
    EDIT: Here is the javascript it is calling.  I'm thinking possibly loop through the whole page and do a variation of the two expand and collapse functions?
    var el = $('#dtt_' + regionId + '_table tbody tr span.dtt_icon')[rownum - 1];
                    if ($(el).hasClass('dtt_collapsed_span')) {
                                   // call expand function
                                   dttExpand(regionId, rownum);
                    } else {
                                   // call collapse function
                                   dttCollapse(regionId, rownum);
    function dttExpand(regionId, rownum) {
      // get related table row
      var el = $('#dtt_' + regionId + '_table tbody tr')[rownum - 1];
      // store current level
      var level = Number($(el).attr('dtt_level'));
      // change icon
      $(el).find('span.dtt_icon').removeClass('dtt_collapsed_span');
      $(el).find('span.dtt_icon').addClass('dtt_expanded_span');
      while ($($(el).next()).attr('dtt_level') != null) {
         var el = $(el).next();
         if ($(el).attr('dtt_level') == (level + 1)) {
          // change display
      el.removeClass('dtt_collapsed_tr');
      el.addClass('dtt_expanded_tr');
      } else if ($(el).attr('dtt_level')  == level) {
      break;
    function dttCollapse(regionId, rownum) {
      // get related table row
      var el = $('#dtt_' + regionId + '_table tbody tr')[rownum - 1];
      // store current level
      var level = Number($(el).attr('dtt_level'));
      // change icon
      $(el).find('span.dtt_icon').addClass('dtt_collapsed_span');
      $(el).find('span.dtt_icon').removeClass('dtt_expanded_span');
      while ($($(el).next()).attr('dtt_level') != null) {
         var el = $(el).next();
         if ($(el).attr('dtt_level') > level) {
          // change display
      el.addClass('dtt_collapsed_tr');
      el.removeClass('dtt_expanded_tr');
      // change icon
      $(el).find('span.dtt_icon').addClass('dtt_collapsed_span');
      $(el).find('span.dtt_icon').removeClass('dtt_expanded_span');
      } else if ($(el).attr('dtt_level')  == level) {
      break;

    Hi Surya
    Create a new HTML region at the top of your page, using No Template and use this as the Source:
    &lt;script type="text/javascript"&gt;
    function showHideAll(displaystyle)
    var hideIMG = "/i/htmldb/builder/rollup_plus_dgray.gif";
    var showIMG = "/i/htmldb/builder/rollup_minus_dgray.gif";
    var k;
    var r = document.getElementsByTagName("DIV");
    if (r)
       for (k = 0; k &lt; r.length; k++)
         if (r[k].className == 't12Hide')
           r[k].style.display = displaystyle;
    var i = document.getElementsByTagName("IMG");
    if ( i )
      for (k = 0; k &lt; i.length; k++)
        if (i[k].id.substr(0, 5) == 'shIMG')
          i[k].src = (displaystyle == 'block') ? showIMG : hideIMG;
    &lt;/script&gt;
    &lt;a href="javascript:showHideAll('block');"&gt;Show All&lt;/a&gt;
    &lt;a href="javascript:showHideAll('none');"&gt;Hide All&lt;/a&gt;The image names and className (t12Hide) are based on my test page - change these as appropriate for your own page (you may need to do a View Source on the page to check these values).
    Andy

  • Expand/Collapse All functionality in TREE UI Element

    Hi All,
    I'm using Tree UI Element in which Collapse All button is coming defaultly in that Tree Application . But i need to know how the function is taking place behind . Because i need to refer to do it for Expand All scenario for the same tree . Is that collapse is refering to any method in class ? . Can anyone brief out the coding of that . Or if anyone knows the coding of Expand all pls refer to me,

    Hello Ramesh Vinay,
    *Create a node which has attributes (EXPANDED, IS_LEAF,ROW_KEY and PARENT_ROW_KEY) to build a tree.
    Following code will be executed when COLLAPSE ALL button is clicked.
    DATA: lo_nd_tree            TYPE REF TO if_wd_context_node,
               lt_elements           TYPE             wdr_context_element_set.
    FIELD-SYMBOLS:
            <lo_element>          TYPE REF TO if_wd_context_element.
    lo_nd_tree = wd_context->get_child_node( name = wd_this->wdctx_tree).
      lt_elements = lo_nd_tree ->get_elements( ).
      LOOP AT lt_elements ASSIGNING <lo_element>.
        <lo_element>->set_attribute(
          EXPORTING value = abap_false
                    name  = u2018EXAPNDEDu2019 ).
      ENDLOOP.
    Following code will be executed when EXPAND ALL button is clicked.
    DATA: lo_nd_tree            TYPE REF TO if_wd_context_node,
               lt_elements           TYPE             wdr_context_element_set.
    FIELD-SYMBOLS:
            <lo_element>          TYPE REF TO if_wd_context_element.
    lo_nd_tree = wd_context->get_child_node( name = wd_this->wdctx_tree).
      lt_elements = lo_nd_tree ->get_elements( ).
      LOOP AT lt_elements ASSIGNING <lo_element>.
        <lo_element>->set_attribute(
          EXPORTING value = abap_true
                    name  = u2018EXAPNDEDu2019 ).
      ENDLOOP.
    Reply me if you have any questions.
    Thanks,
    Bharath.K

  • Can I expand/collapse all of my email accounts in the folder pane?

    Greetings,
    Thank you in advance for your help.
    I'm using T-bird v31.0
    The inbox is configured to view/layout/folder pane and view/folders/unified.
    I have multiple email accounts that appear in the folder pane.
    I can expand/collapse inbox, drafts, sent, junk, trash, but not the email accounts.
    Is it possible to expand/collapse the email accounts?
    Thank you for you hard work and expertise.
    norm

    Do you have the removed account forwarded to your other account at the server?
    If the account is not still in Thunderbird there is no way for it to check mail on that account. Even if it did it would not place the messages in a different Inbox.
    Just to be sure when you go to Tools-Account Settings is the old account still in the list?
    Use Tools on the menu bar and not the AppMenu button.
    No menu bar? Press the alt key.

  • The Create List Item workflow action does not work in document library with document template

    My end goal is more complex but below is a basic example of the issue I’m having that just simply does not work.
    I'm trying to use a site workflow to create an item in a document library that has a document template applied to it but the file that gets created by the workflow is corrupt and cannot be opened.
    I created a document library and edited the document template by adding some text to the header and changing it to a Word docx file instead of a Word dotx file. I tested the document template by clicking the files tab in the ribbon and then clicking new
    document which opens the document template in Word and allows me to edit and save the document back to SharePoint. Then I created a SharePoint 2013 site workflow in SharePoint Designer that contains a single Create List Item action, and that action creates
    an item in the document library with the name field statically defined. I published the workflow and then manually start it on the site. The workflow completes successfully and when I navigate to the document library the document has been created by the workflow.
    When I click on the document to open it in the Word Web App it throws the error pictured below and if I open it in the Word client application it just opens a blank document and not the correct document template.
    I also tried using a SharePoint 2010 workflow with pretty much the same results. Opening the document in Word Web App gives the same error as above and opening the document in the Word client application gives the error pictured below.
    Come on Microsoft creating a Word Document in a SharePoint Document Library from a SharePoint Workflow should just work! Is this a bug or does anyone have any ideas on what is causing the this issue?

    I had the same problem with corrupted document - this worked for me:
    1. Create a 2010 Workflow which creates the list element in a document library
    (you may start this workflow from your 2013 workflow if applicable)
    2. In the Create New List Item properties - make sure to set ContentTypeId to your content type
    ("Id for indholdstype" is Danish for "Contenttype ID")
    3. Your Content Type template should be a ".docx" file - NOT a ".dotx" file...!
    (I have always created my templates for content types as .dotx files - seems Microsoft wants us to use ordinary .docx files as template files for content types)
    Hope this helps you!

  • Expand/Collapse a tree using a Left Handed Mouse not working

    I have a couple of forms that use a tree item. If I set my mouse to be left handed I can no longer select a node on the tree or expand and collapse the nodes.
    I'm using Oracle JInitiator: Version 1.3.1.17 and Forms [32 Bit] Version 9.0.4.0.19 (Production).
    Is Oracle Forms Leftist? :)
    Richard

    Hi, stumbled on this today...not a real techie fix but may be useful in your projects...
    Left handed mouse setup as per MS Windows Mouse settings only allowed switching of primary and secondary mouse button function...(XP Pro).
    Happened upon an NT Workstation and attempted to setup mouse as above, however on this workstation there was an MS Intellimouse set of software (5.2/4.1) in the mouse setup.
    I switched the buttons to make it left handed...
    Accessed our application and set about navigating the left hand tree, it worked normally single clicking on each node...prior to this the left tree was awkard for left hand mousers.
    Installed these drivers on XP machine and same results...left hand tree works fine..
    sorry if this low tech but I am a front end user rather than a coder.
    Cheers..........Nige

  • Calendar items with Actions no longer work

    It appears that actions attached to a calendar item are now completely broken or just missing. I can no longer attach a custom action to run on a calnedar event, and items on my calendar that had actions no longer seem to have them attached. Was this really completly removed?

    I believe your suggestion is exactly right.  I ended up tossing the whole Motion folder - which was probably empty except for those presets.  I realized that some miscommunication between FCP X and Motion was involved, when the generators began reappearing in FCP X, once I opened a copy of one in Motion, but disappeared again, when I closed Motion.
    I believe Apple was quite right to recommend putting the new versions on a separate startup volume, but getting rid of those presets was enough to get everything working again for me.
    Thanks!

  • Adding a link to expand and collapse all DHTML drop downs

    Hi, can anyone help me adapt the "Skinny on Skins" example "Add a Toolbar button to expand and collapse all DHTML drop downs" so that it will work with just a simple HTML link in RH8, instead of being attached to a custom skin button?
    The example looks like this:
    Step 1. Open the Skins Editor for the skin where you want to add the button.
    Step 2. After the preview loads into the window, ensure that the Toolbar tab has focus, then click the plus symbol. The Custom Toolbar Item dialog should display.
    Step 3. Type the Item Name (This is simply an internal reference for the button).
    Step 4. Type the Text (This is the text that will be seen by the end user. The field must contain something. So if you don't want any verbiage to display for your toolbar item, simply type a space.)
    Step 5. Choose your Image Options, then click the Action tab.
    Step 6. Click the JavaScript option button.
    Step 7. Enter the following code in the OnClick field:
    javascript:toggle()
    Step 8. In the JavaScript area, ensure the Inline JavaScript option button is selected, then click the edit (Pencil) icon located to the right.
    Step 9. Enter the following code in the Inline JavaScript dialog
    var show = "false";
    function toggle() {
    parent.frames[1].bsscright.focus();
    var arrayofDivs = parent.frames[1].bsscright.document.all.tags('DIV');
    if (show == "false") {
    for (x=0;x<arrayofDivs.length;x++) { arrayofDivs[x].style.display = "block";}
    show = "true";}
    else {
    for (x=0;x<arrayofDivs.length;x++) { arrayofDivs[x].style.display = "none"; }
    show = "false"; }
    Step 10. Click the OK button to close the Inline JavaScript dialog.
    Step 11. Click the OK button to close the Custom Toolbar Item dialog.
    Step 12. Click the OK button to close the Skin Editor.
    Step 13. Generate WebHelp via File > Generate > WebHelp and ensure that you have the new button selected with a check mark. This will probably require stepping through some screens to see the place where you can select it.
    Many thanks
    Jonathan

    Hi again
    I want to use it in the header of one of my Master Pages, so it will only be created/maintained once. Not all my pages have drop downs in so rather than have a toolbar button available for every page, I was trying to be a bit cuter by having two Master Pages - one for normal pages and one for pages with drop downs in.
    I'm no javascript expert so I'll see if one of my developers can help.
    Thanks anyway
    Jonathan

Maybe you are looking for