PDA

View Full Version : [FIXED] DataView (like List) should use the getter function of an Model



SunboX
24 Oct 2011, 8:26 AM
If I overwrite a Models getter, it does not apply to an DataView instance. Take a look at this demo:

http://jsfiddle.net/QYJpc/7/

Demo Code:
Ext.require([
'Ext.data.Store',
'Ext.List'
]);

Ext.define('TestModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'distance', type: 'string'}
],
get: function(key){
if(key == 'distance'){
// calculate distance
return '555 m';
}
return this.callParent(arguments);
}
});

Ext.setup({
onReady: function() {

var store = Ext.create('Ext.data.Store', {
model: 'TestModel',
data : [
{name: 'Ed', distance: '100 m'},
{name: 'Tommy' },
{name: 'Aaron' },
{name: 'Jamie' }
]
});

Ext.create('Ext.List', {
fullscreen: true,
title: 'Demo Time',
itemTpl: '{name} - {distance}',
store: store
});
}
});

greetings Sunny

Jamie Avins
31 Oct 2011, 11:24 AM
Indeed it should, thank you for the report.