Liooo / jquery-datatables-row-grouping

Automatically exported from code.google.com/p/jquery-datatables-row-grouping
0 stars 0 forks source link

Two level collapsed grouping #45

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Basically, I am trying to use two level collapsible row grouping. I want to 
start out with all the groups collapsed (i.e., 2nd level groups hidden because 
the first level is collapsed).
Basically, I do 
$('#example').dataTable(({ "bLengthChange": false, "bPaginate": false}))
       .rowGrouping({bExpandableGrouping: true,
                     iGroupingColumnIndex2: 2,
                     bExpandableGrouping2: true,
                     asExpandedGroups2: [], asExpandedGroups: []});

What is the expected output? What do you see instead?
This should collapse all the groups, but it collapses the second level and 
leaves the first level expanded since its second level children are visible.

The produced code can be seen at 
http://yasirs.github.com/jquery-datatables-row-grouping-double-collapse/

Original issue reported on code.google.com by yasir.su...@gmail.com on 7 Nov 2012 at 12:24

GoogleCodeExporter commented 8 years ago
I had the same requirement that I need to collapse all 2-level grouped table.
What I have is add click method in '_fnOnGrouped()':
function _fnOnGrouped() {
    $('.group, .subgroup').click();
}
This is dumb solution, but it seems to work for me.

Original comment by khs...@gmail.com on 15 Nov 2012 at 7:26

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I've got the same requirements too, and i'm facing the same trouble. Plus, the 
'dumb solution' proposed by khs...@gmail.com doesn't work for me.

Also, it would be nice if expanding the first level grouping the second one was 
showed collapsed. As in the live example by yasir.su...@gmail.com, this is 
never the case, at the moment.

Original comment by roberto....@horosweb.com on 5 Mar 2013 at 11:56

GoogleCodeExporter commented 8 years ago
Same issue. I want all the rows collapsed during the initial load!alas not 
working

Original comment by ta.sethu...@gmail.com on 16 Mar 2013 at 5:41

GoogleCodeExporter commented 8 years ago
I've managed to modify the plugin to achieve the described behaviour. In the 
attachment, my modified version of it. Everything is commented as "//Roberto 
A****** - Two-level grouping optimization"

Let me know if this fix is going to be merged in the forecoming versions of 
jquery.datatables.grouping.js

Original comment by roberto....@horosweb.com on 19 Mar 2013 at 11:35

Attachments:

GoogleCodeExporter commented 8 years ago
I found an issue with the fix that Roberto did (which works awesome, thanks!)

The problem is after you collapse the second group once, it won't expand. To 
fix this, I uncommented the code shown below:

                //Roberto A****** - Two-level grouping optimization
                aoGroups[sGroup].state = "collapsed"; //(standard code - uncommented now to fix issue)
                for(var i in aoGroups) {
                    if (aoGroups[i].key.match(sGroup) != null)
                        aoGroups[i].state = "collapsed";
                }
                //Roberto A****** - End of Two level grouping optimization

I'm not sure if this will cause any other issues, but so far it seems to be 
working.

Original comment by sva...@gmail.com on 18 Sep 2013 at 2:34