PDA

View Full Version : Dataview not loading Store in the XTemplate



agunescu
26 Feb 2014, 1:39 AM
I'm trying to make a dataview work (on Ext JS 4.2.2), but store is not loading data.
I have a weird problem, I have a view, a store and a model that work in ExtJS 4.0.1 but after migrating to ExtJS 4.2.2 it fails to load.

the model :



Ext.define('Field', {
extend: 'Ext.data.Model',
fields: [
{ name:'text', type:'string' },
{ name:'dataIndex', type:'string' },
{ name:'icon', type:'string' }
]
});



the store:



var leftHandStore = Ext.create('Ext.data.Store', {
model: 'Field',
data : record.get('leftHand') //data is loaded
});



the view:



var picklistTpl = new Ext.XTemplate(
'<div class="ria-picklist-inner">',
'<tpl for=".">',
'<div class="list-entry">',
'<div style="white-space: nowrap; float: left; padding-left: 5px; width: 130px;">{text}</div>',
'</div>',
'</tpl>',
'</div>',
'<br/>'
);
Ext.define('MyApp.view.export.PickList', {
extend: 'Ext.view.View',
listeners: {
added: function(cmp){
/* setting multiSelect property is now deprecated
* http://docs.sencha.com/ext-js/4-1/#!/api/Ext.view.AbstractView-cfg-multiSelect.
* Using Ext.selection.Model.mode 'MULTI' instead, suggested.
* (though multiSelect: true option still works)
*/
var selModel = cmp.getSelectionModel();
selModel.setSelectionMode('MULTI');
}
},
alias: 'widget.picklist',
tpl: picklistTpl,
itemSelector: 'div.list-entry',
overItemCls: 'list-entry-over',
selectedItemCls: 'list-entry-selected',
trackOver: true,
cls: 'ria-picklist'
});



When I set the data directly in the store as inline data it doesn't work:



myview.down('#leftHand').store = leftHandStore;



So is there something wrong in my way of using DataView or Store classes?
Any help would be appreciated

mitchellsimoens
3 Mar 2014, 8:23 AM
Just updating the property isn't going to work, Javascript doesn't know when you update a property, you need to use a method. Ext.view.View has a bindStore method you should be able to use to update the store instance it is bound to.

agunescu
3 Mar 2014, 11:23 AM
Thanks very much for your answer. I've found this fix last week. The question is why was it working on version 4.1 and not on 4.2?