It seems native grid functionality doesn't support what you're trying to accomplish, but there is a workaround available by altering your data structure to fit the desired view.
I've made some modifications to a fiddle someone else created here: http://jsfiddle.net/SugMK/47/
To begin with, you need to group your data based on a unique identifier like uid
:
var result = _.groupBy(result, (item) => { return item.uid });
Next, iterate through the resulting object which will have a structure similar to:
{
uid1: [
{row1_with_uid1},
{row2_with_uid1}
],
uid2: [
{row1_with_uid2},
{row2_with_uid2}
]
}
And then aggregate the necessary rows using custom logic. In your case, combining two code
fields as text with a br
separator:
_.forEach(result, (items) => {
var newItem = items[0]; // set default.
items.splice(0, 1); // remove first item from aggregation array
_.forEach(items, (item) => { newItem.code = newItem.code + "<br />" + item.code; }); // aggregate items
newResult.push(newItem); // save aggregated item
});
Finally, make sure to set the encoded
parameter of the aggregated field (code
) to false
so that the br
's are interpreted as HTML, not text:
{ field: "code", title: "multiline", encoded: false }
P.S. While I believe a better solution can be devised, I hope this example helps in understanding the concept.