Hey everyone.
Here is the code I have been using for the list of items described. I have no other components in this DataView list by the look of things. Would the size of my XTemplate have anything to do with performance issues?
I did try cutting down the template significantly and the performance was still quite slow.
Code:
var storylistpanel = Ext.define('Application.view.MyItemList', {
extend: 'Ext.dataview.DataView',
xtype: 'myitemlistpanel',
requires: [
'Ext.dataview.DataView',
'Application.store.Items',
'Ext.plugin.PullRefresh',
'Ext.plugin.ListPaging'
],
config: {
xtype: 'dataview',
scrollable: {
direction: 'vertical'
},
loadingText: false,
html: '<div class="loading">'
+ '<h2 class="loading-logo">'
+ '</h2>'
+ '<h4>CHECKING...</h4>'
+ '<ul>'
+ '<li>Loading....</li>'
+ '</ul>'
+ '</div>',
plugins: [
{
xclass: 'Ext.plugin.PullRefresh',
pullRefreshText: 'Pull to refresh',
refreshFn: function(plugin){
application.app.item_offset = 0;
application.app.item_limit = 10;
plugin.up().getStore().load({
params: {
start: application.app.item_offset,
finish: application.app.item_limit
},
callback: function(){
Ext.each(Ext.query('.item'), function(item){
item.style.display = 'inline';
});
}
});
}
},
{
xclass: 'Ext.plugin.ListPaging',
loadMoreText: 'Loading more items',
autoPaging: true,
loadNextPage: function(){
myitemlistpanel = Ext.ComponentQuery.query('myitemlistpanel')[0];
store = myitemlistpanel.getStore();
application.app.item_offset += 10;
application.app.item_limit += 10;
store.load({
params: {
start: application.app.item_offset,
finish: application.app.item_limit
},
callback: function(){
Ext.each(Ext.query('.item'), function(item){
item.style.display = 'inline';
});
}
});
}
}
],
itemTpl: Ext.create(
'Ext.XTemplate',
'<div class="item-wrapper">'
+ '<article class="item">'
+ '<div class="top-item-wrapper">'
+ '<div class="box-shadow">'
+ '<div class="item-img" style="background-image:url({image})">'
+ '</div>'
+ '</div>'
+ '<div class="item-head"">'
+ '<h2>{headline}</h2>'
+ '<div class="meta">'
+ '<img src="{location}.png" width="31" height="17" alt="{location}" />'
+ '</div>'
+ '</div>'
+ '<p>{item_description}</p>'
+ '</div>'
+ '<tpl if="relatedItemCount > 0">'
+ '<div class="related-item">'
+ '<a class="rel-trigger">See related Items({relatedItemCount})</a>'
+ '<div class="list">'
+ '</div>'
+ '</div>'
+ '</tpl>'
+ '</article>'
+'</div>',
{
itemsNum: function(score){
//code to calculate integer
return 0;
},
topNum: function(topscore){
//more code to calculate something
return 0;
}
}
),
store: 'Items',
listeners: {
painted: function(){
application.app.item_offset = 0;
application.app.item_limit = 10;
store = this.getStore();
store.setProxy({url: application.app.url});
store.load({
params: {
start: application.app.item_offset,
finish: application.app.item_limit
},
callback: function(){
setTimeout(function(){
Ext.query('.loading')[0].style.display = 'none';
Ext.each(Ext.query('.item'), function(item){
item.style.display = 'inline';
});
Ext.query('.x-list-paging')[0].style.display = 'inline';
}, 2000);
},
scope: this
});
},
erased: function(){
Ext.query('.loading')[0].style.display = 'inline';
Ext.each(Ext.query('.item'), function(item){
item.style.display = 'none';
});
}
}
}
});