| Support Center

(Back to Website)

Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Grouping Toggle / Untoggle All

Matt Sep 26, 2017 09:29AM PKT

Hi Abu,

I've got a grid with 2 nested layers of grouped items which is working fine:

$grid["groupingView"]["groupField"] = array("name","coupon");

What I would like to do is have a "+" button either in the header or in the buttons at the bottom of the table that will collapse or expand all the grouped rows. I've searched in the forum and found the code for a similar thing for SubGrids however can't make it work for Groups.

https://phpgrid.desk.com/customer/portal/questions/6970287-subgrid-expand-all

I can see the code that runs when clicked the +/- is:
onclick="jQuery('#list1').jqGrid('groupingToggle','list1ghead_1_516');return false;

I want to get all the 'list1ghead_#####' items and loop through them to collapse/expand. Ideally as well since it is nested is there a way to have a collapse/expand all option inside the nesting, i.e when I click the first "+" to show the sub grouped items there is an option inside there to only expand all those under the first layer of the nest?

Thanks mate,

Matt

Up 1 rated Down
Abu Ghufran Sep 30, 2017 05:43AM PKT PHP Grid - Support Center Engineer
Hello,

You can review online demo
http://phpgrid.org/demo/demos/appearance/grouping.php

and code:
http://phpgrid.org/demo/demos/appearance/grouping.phps#L.232

It allow toggle all to collapse/expand state.
Up 0 rated Down
Matt Oct 03, 2017 02:38AM PKT
Thanks Abu, I was able to get it to work ok with a minor modification to the demo code. Here's the addition for anyone else wanting to do something similar:

jQuery("#toggleSubGroups").click(function()
{
jQuery("."+grid_id+"ghead_0").each(function(){
jQuery("#"+grid_id).jqGrid('groupingToggle',jQuery(this).attr('id'));
});

jQuery("."+grid_id+"ghead_1").each(function(){
jQuery("#"+grid_id).jqGrid('groupingToggle',jQuery(this).attr('id'));
});
});

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Contact Us

  • Post a Public Question
  • Email Us
  • Live Chat!
  • Ask the Community

    Instructions

    • Paste complete code that is involved in your question. You can use pastebin.com to share code link.

    Screenshots or Online link of webpage is helpful in resolution. You can also send email at address mentioned below.

    • To report an issue, Write steps to regenerate the case.

    • For email support or live chat, Use gridphp@gmail.com and add it in Google Chat.
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete