A function to concatenate field values in a store
Published on 7/26/2012
Below is a function to concatenate the values in a field in a store. This is similar to Store.sum();
Ext.data.Store.override({
concat: function(field, grouped, separator){
if(typeof separator === 'undefined'){
separator = ', ';
}
if (grouped && this.isGrouped()) {
return this.aggregate(this.getConcat, this, true, [field, separator]);
} else {
return this.getConcat(this.data.items, field, separator);
}
},
getConcat: function(records, field, separator){
var result = [];
var i = 0;
var len = records.length;
for(; i < len; ++i){
result.push(records[i].get(field));
}
return result.join(separator);
}
});
For example, if the store has a field ‘email’, with data ‘[email protected]’ and ‘[email protected]’, then store.concat(‘email’) would return ‘[email protected], [email protected]’
... views