Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
How to define groupText if groupField has more as one items
Tags: grouping
12/09/2010
18:56
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi Tony,

I could not find a way how to display the second item from the groupField. For example if I change in the example from http://www.ok-soft-gmbh.com/jq.....m the groupField : ['subSource'] to

groupField : ['source', 'subSource']

I could not modify

groupText: ['<b>{0} - {1} Item(s)</b>']

in any way so that the information about the second item ('subSource') will be displayed. What would be mean groupText: ['<b>{0} - {1} Item(s)</b>', '{0} - {1} Item(s)'] for example? Where should be displayed the second element of the groupText array?

The the worst case it seems to me more correct to display the last grouping index in the groupText. For example if you will group by 'source' and 'subSource' (see the link to the example above), then the 'subSource' names are more informative as the information from the 'source'. Isn't it?

It could be that the grouping with more as one grouping fields not yet works in jqGrid?

Thanks
Oleg 

04/08/2011
00:50
Avatar
kccarter
Salt Lake City, UT
Member
Members
Forum Posts: 6
Member Since:
04/08/2011
sp_UserOfflineSmall Offline

you can enable multiple mapping for the group by text with the following code:

groupingRender: function(c, b) {
            return this.each(function() {
                var a = this, d = a.p.groupingView, e = "", g = "", j, m = "", n = [], q, k;
                if (!d.groupDataSorted) {
                    d.sortitems[0].sort();
                    d.sortnames[0].sort();
                    if (d.groupOrder[0].toLowerCase() == "desc") {
                        d.sortitems[0].reverse();
                        d.sortnames[0].reverse()
                    }
                }
                m = d.groupCollapse ? d.plusicon : d.minusicon;
                m += " tree-wrap-" + a.p.direction;
                for (k = 0; k < b; ) {
                    if (a.p.colModel[k].name == d.groupField[0]) {
                        q = k;
                        break
                    }
                    k++
                }
                f.each(d.sortitems[0], function(h, l) {
                    j = a.p.id + "ghead_" + h;
                    g = "<span style='cursor:pointer;' class='ui-icon " + m + "' onclick=\"jQuery('#" + a.p.id + "').jqGrid('groupingToggle','" + j + "');return false;\"></span>";
                    try {
                        n.push(d.groupText[0]);
                        jQuery(d.groupField).each(function(index, field) {
                            n.push($($('td', $(c[l][0].join()))[a.p.colNames.indexOf(field)]).text());
                        });
                    } catch (u) {
                        n = [d.groupText[0], d.sortnames[0][h]];
                    }
                    n.push(c[l].length);
                    e += '<tr id="' + j + '" role="row" class= "ui-widget-content jqgroup ui-row-' + a.p.direction + '"><td colspan="' + b + '">' + g + f.jgrid.format.apply(this, n) + "</td></tr>";
                    for (h = 0; h < c[l].length; h++)
                        e += c[l][h].join("");
                    if (d.groupSummary[0]) {
                        h = "";
                        if (d.groupCollapse && !d.showSummaryOnHide)
                            h = ' style="display:none;"';
                        e += "<tr" + h + ' role="row" class="ui-widget-content jqfoot ui-row-' + a.p.direction + '">';
                        h = d.summaryval[0][l];
                        for (var o = a.p.colModel, p, r = c[l].length, i = 0; i < b; i++) {
                            var s = "<td " +
                            a.formatCol(i, 1, "") + ">&#160;</td>", t = "{0}";
                            f.each(h, function() {
                                if (this.nm == o[i].name) {
                                    if (o[i].summaryTpl)
                                        t = o[i].summaryTpl;
                                    if (this.st == "avg")
                                        if (this.v && r > 0)
                                            this.v /= r;
                                    try {
                                        p = a.formatter("", this.v, i, this)
                                    } catch (v) {
                                        p = this.v
                                    }
                                    s = "<td " + a.formatCol(i, 1, "") + ">" + f.jgrid.format(t, p) + "</td>";
                                    return false
                                }
                            });
                            e += s
                        }
                        e += "</tr>"
                    }
                    n = [];
                });
                f("#" + a.p.id + " tbody:first").append(e);
                e = null;
            }
04/08/2011
02:33
Avatar
kccarter
Salt Lake City, UT
Member
Members
Forum Posts: 6
Member Since:
04/08/2011
sp_UserOfflineSmall Offline

in order to maintain compatibility with IE the following needs to be done

if (Array.prototype.indexOf === undefined) {
    $.extend(Array.prototype, (function () {
        function indexOf(item) {
            for (var i = 0; i < this.length; i++) {
                if (this[i] === item) {
                    return i;
                }
            }
            return -1;
        }

        return {
            indexOf: indexOf
        };
    })());
}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
63 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information