JQGrid Grouping GroupText formatting and modification

I have a grid that implements grouping, but would like to expand the details displayed in the groupText: area. Ideally, I could take data about this grouping and display in this group a row with the name of the group ({0} is the default value).

In other words, what I'm trying to achieve is a way to map not only the group name, but also some other data items contained in the JSON channel to the grid.

My search seems to be close to who can achieve this, but I hope that someone can shed light on expanding this setting and providing access to create this area.

+5
source share
1 answer

, . , .

, . :

enter image description here

, : . , , . , , .

, , "(test4, test7)", , .

"", formatter: 'date'. , :

formatter: function (cellval, opts, rowObject, action) {
    var fullOpts = $.extend({}, $.jgrid.formatter.date, opts),
        formattedDate = $.fmatter.util.DateFormat('Y-m-d', cellval, 'd-M-Y', fullOpts),
        groupIdPrefix = opts.gid + "ghead_",
        groupIdPrefixLength = groupIdPrefix.length,
        month = Number(cellval.split('-')[1]), // input format 'Y-m-d'
        names = [], data, i, l, item;

    // test wether opts.rowId start with opts.gid + "ghead_" and integer
    // and rowObject is the array and action is undefined.

    if (opts.rowId.substr(0, groupIdPrefixLength) === groupIdPrefix && typeof action === "undefined") {
        // custom formating of the group header
        // we just simulate some login by testing of the month > 9

        // the next code fragment is not effective, but it can be used
        // in case of not so large number of groups and the local data
        data = $(this).jqGrid("getGridParam", "data");
        for (i = 0, l = data.length; i < l; i++) {
            item = data[i];
            if (item.invdate === cellval) {
                names.push(item.name);
            }
        }

        return (month > 9 ? ('<span class="ui-icon ui-icon-alert" style="float: left;"></span>' +
            '<span style="color:tomato; margin-left: 5px;">') : "<span>") +
            formattedDate + ' (' + names.join() + ')</span>'
    }
    return formattedDate;
}

. . $.fn.fmatter jqGrid $.fmatter.util.DateFormat.

+8

All Articles