A function to concatenate field values in a store
This is a function to concatenate the values in a field of a store 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 'names', with data 'Me' and
'You', then store.concat('name') would return 'Me, You'
No comments:
Post a Comment