jQWidgets Forums

jQuery UI Widgets Forums Grid Get Group Index

This topic contains 6 replies, has 3 voices, and was last updated by  revilo7 10 years, 2 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Get Group Index #47027

    aoverton07
    Participant

    I am trying to expand/collapse a group when the group header row is clicked with the ‘expandgroup’ and ‘collapsegroup’ methods. Both of these methods accept the groups index (integer) and I cannot figure out a way to get this value. I know that the click event args contains the name of the group, but not the index.

    Is there anyway to retrieve the groups index?

    It seems that there are multiple methods that require this argument, yet there are no ways of getting it. Must it be arbitrarily supplied?

    Thanks is advance!

    Get Group Index #47053

    Peter Stoev
    Keymaster

    Hi aoverton07,

    Groups Index starts from 0.The first group’s index is 0, the second one is 1 and so on.

    If you know the group’s Name, you can easily learn its index.

    Example:

                // trigger expand and collapse events.
                $("#jqxgrid").on('groupexpand', function (event) {
                    var args = event.args;
                    $("#expandedgroup").text("Group: " + args.group + ", Level: " + args.level);
    
                    var rows = $("#jqxgrid").jqxGrid('getdisplayrows');
                    var groupIndex = -1;
                    for (var i = 0; i < rows.length; i++) {
                        if (rows[i].level === args.level) {
                            groupIndex++;
                            if (args.group == rows[i].group) {
                                break;
                            }
                        }
                    }
                    alert(groupIndex);
                });
    

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Get Group Index #47085

    aoverton07
    Participant

    I am trying to feed the groups index to the ‘expandgroup’ and ‘collapsegroup’ methods so it does not make sense to get the groups index from the ‘groupexpand’ event, I need to the index so that I know WHICH group to expand. Is there any other way to get the groups index (level) besides the ‘groupexpand’ and ‘groupcollapse’ event handlers?

    Get Group Index #47086

    Peter Stoev
    Keymaster

    Hi aoverton07,

    The first group’s Index is 0, the second group’s Index is 1 and so on. Through API, you can expand or collapse Root groups.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Get Group Index #47089

    aoverton07
    Participant

    Peter,

    Could you provide a solution where a group is expanded when the Group Details Row is double clicked?

    Best Regards,

    Alex Overton

    Get Group Index #47090

    Peter Stoev
    Keymaster

    Hi Alex,

    The feature you’re looking for is not available.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Get Group Index #68765

    revilo7
    Participant

    Hello!
    I was trying somethin similar. My objective was to expand/collapse a group when its group row is clicked. Here’s how I accomplished it.

    if (event.args.rowindex == -1 && event.args.row.group != undefined) {
    var iter = true;
    var groupIndex = 0;
    while (iter) {
    if ($(‘#jqxGrid’).jqxGrid(‘getgroup’, groupIndex).group == event.args.row.group) {
    iter = false;
    break;
    }
    groupIndex += 1;
    }
    $(‘#jqxGrid’).jqxGrid($(‘#jqxGrid’).jqxGrid(‘getgroup’, groupIndex).expanded ? ‘collapsegroup’ : ‘expandgroup’, groupIndex);
    return;
    }

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.