row grouping considering 2 columns (multi level grouping)

row grouping considering 2 columns (multi level grouping)

prabs_devprabs_dev Posts: 3Questions: 1Answers: 0

Link to test case: https://live.datatables.net/xabovohu/3/edit
Debugger code (debug.datatables.net):
Error messages shown: Doesn't work - with each row displayed as "undefined (1)"
Description of problem:

Hello,

I am new to datatable implementation with very less JS knowledge. I must appreciate all who work behind this awesome libraries that simplified the way data tables are rendered.

As mentioned in the test case, I am unable to get the 2 columns grouping work.

Can someone help me with this, please?

Appreciate i might have missed something very basic, but unable to get to the bottom of what that is :(

Best Regards,
Prabhu.

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 20,993Questions: 26Answers: 4,887
    Answer ✓

    You are using an old version of RowGroup (1.0.2). This is from the rowGroup.dataSrc docs:

    array
    Description:
    As of RowGroup 1.1.0 it is possible to nest multiple levels of data by providing this parameter as an array of values.

    I updated the tet case to use RowGroup version 1.5.0 from the Download Builder.
    https://live.datatables.net/xabovohu/4/edit

    Kevin

  • prabs_devprabs_dev Posts: 3Questions: 1Answers: 0

    Hi @kthorngren

    Much appreciated. Just 2 more final cosmetic requests from my end.

    1. I would like the table to appear as in https://live.datatables.net/nitemova/1/edit
    2. Every time the page loads, I would like the first level only is collapsed

    Could you kindly assist, please?

  • kthorngrenkthorngren Posts: 20,993Questions: 26Answers: 4,887
    edited June 19 Answer ✓

    This code wasn't executed so commented it out, you won't need it.

     $('#example tbody tr.group-start').each(function() {
        var name = $(this).data('name');
        collapsedGroups[name] = !collapsedGroups[name];
      });
    

    The code needs to check if the first level is not in the collapsedGroups object and default it to true to start collapsed or false to start expanded. Updated code:

                    if (level === 0) {
                      // If parent group not defined then initializing so default it to collapsed (true)
                      if (collapsedGroups[group] === undefined) {
                        collapsedGroups[group] = true;
                      }
                        top = group;
                        all = group;
    

    There were a couple spots where is had !!collapsedGroups. I removed the !! which is a double negative.

    I added a couple console log statements so you can see what how the collapsedGroups variable is handled.

    https://live.datatables.net/xabovohu/6/edit

    Kevin

  • prabs_devprabs_dev Posts: 3Questions: 1Answers: 0

    Thanks a ton Kevin! You are a star!! God Bless You!!

Sign In or Register to comment.