Using labels in Grid Hedears for values


#1

Hi ,
To reduce the size of data recive from the server my dataset looks like this
[
{
“A”: “XXXXXX”,
“B”: “xxxxxx”,
“C”: “3000”,
“D”: “YYYYYY”,
“E”: “2017-08-16”,
“F”: “2017-08-16”
},
{
“A”: “ZZZZZZ”,
“B”: “zzzzzz”,
“C”: “3000”,
“D”: “VVVVVV”,
“E”: “2017-08-16”,
“F”: “2017-08-16”
},

]
On grid constructor I specified labels for all ids

fieldList: [

{ id: “A”, label: “Produs” },
{ id: “B”, label: “Tip Limita” },
{ id: “C”, label: “Suma aprobata”,width:150 },
{ id: “C”, label: “Unitatea” },
{ id: “D”, label: “Sucursala” },
{ id: “E”, label: “Data cerere”, type: “date”, format: “%Y-%m-%d” },
{ id: “F”, label: “Data postare flex”, type: “date”, format: “%Y-%m-%d” }
]

On the pivot setting labels apear correct , but on grid header ids are use instead of labels . How can i show labels ?



#2

It no longer matters, I modifed a function and now show’s label instead of ID

 t.prototype._getHeader = function (t) {
            var e = this, i = 0, o = this.$config.pivot.values;
            if (o) {
                var n = this._rows.map(function () {
                    return {header: [{text: ""}], width: e._firstColsWidth, id: (i++).toString()}
                }), s = [], a = [], d = [];
                t = this._getHeaderLabels(t, this._header);
                for (var h = 0; h < t.length; h++) for (var l = 0, c = o; l < c.length; l++) {
                    for (var u = c[l], _ = [], f = 0; f < t[h].length; f++) {
                        var p = t[h][f].id || t[h][f];
                        s[f] = s[f] || [], a[f] = a[f] || 1, d[f] = d[f] || {}, s[f] !== p ? (s[f] = p, d[f] = {
                            text: p,
                            colspan: a[f]
                        }, _.push(d[f])) : (d[f].colspan++, _.push({text: null}))
                    }
                    _.push({text: (u.label||u.id) + " (" + r.default[u.method] + ")"});
                    var g = {header: _, width: 151, id: i++};
                    this.$config.layout && this.$config.layout.rowsWidth && (g.width = this.$config.layout.rowsWidth), n.push(g)
                }
                return n
            }
        }

line modified was

_.push({text: u.id + " (" + r.default[u.method] + “)”});

in
_.push({text: (u.label||u.id) + " (" + r.default[u.method] + “)”});


#3

Hi,

The similar fix will be included in Pivot 1.1