mardi 17 février 2015

How to handle request errors on Store

I'm trying to show an error information in my app.

I tried 3 different cases and in all is the same situation.

404 error, JSON Reader error and nonexistent URL.

In my Store added a load listener to verify the success and the store.isLoaded().

In all cases the success returns false but store.isLoaded() returns true and I think it makes a blank page load.

I think that should show the emptyText list property since it was not loaded any content.

How to handle it?

I'm calling Store.load() in the list initialize method.



Code:



Ext.define('Amib.view.EventsList', {
extend: 'Ext.dataview.List',
xtype: 'eventslist',


config: {
cls: 'eventslist',
disableSelection: true,
height: '100%',
scrollable: 'vertical',
store: 'events',
itemTpl: new Ext.XTemplate(
'<div class="title">{title}</div>',
'<div class="date">{date}</div>',
'<div class="location">{location}</div>',
'<tpl if="link">',
'<div class="more">',
'<input type="button" class="link" id="{link}" value="More Info"/>',
'</div>',
'</tpl>'
),
listeners: {
initialize: function (list) {
list.getStore().load();
},
itemtap: function (list, index, target, record, event) {
if (Ext.get(event.target).hasCls('link') && !Ext.isEmpty(record.get('link'))) {
Amib.app.getController('Base').openURL(record.get('link'), true);
}
}
}
}
});


Code:



Ext.define('Amib.store.Events', {
extend: 'Ext.data.Store',
config: {
autoLoad: false,
model: 'Amib.model.Event',
storeId: 'events',
proxy: {
type: 'ajax',
url: 'http://ift.tt/1vSMS38',
noCache: false,
enablePagingParams: false,
reader: {
type: 'json',
rootProperty: 'items'
}
}
}
});





How to handle request errors on Store

Aucun commentaire:

Enregistrer un commentaire